From 4496a697eb98798ed41ff53a87f51e0ae1bcf336 Mon Sep 17 00:00:00 2001 From: Denys Zadorozhnyi Date: Thu, 16 Nov 2023 10:51:48 +0200 Subject: [PATCH] fix: fix build after rebase --- codegen/masm/src/masm/program.rs | 1 + tests/integration/expected/and_bool.masm | 603 +++++++++++++++++++++++ tests/integration/expected/and_i16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/and_i32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/and_i8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/and_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/and_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/and_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_i16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_i32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_i64.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_i8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_u64.masm | 603 +++++++++++++++++++++++ tests/integration/expected/eq_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/fib.masm | 603 +++++++++++++++++++++++ tests/integration/expected/ge_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/ge_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/ge_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/gt_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/gt_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/gt_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/le_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/le_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/le_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/lt_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/lt_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/lt_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/not_bool.masm | 603 +++++++++++++++++++++++ tests/integration/expected/not_i16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/not_i32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/not_i8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/not_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/not_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/not_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/or_bool.masm | 603 +++++++++++++++++++++++ tests/integration/expected/or_i16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/or_i32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/or_i8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/or_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/or_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/or_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/shr_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/shr_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/shr_u8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/xor_bool.masm | 603 +++++++++++++++++++++++ tests/integration/expected/xor_i16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/xor_i32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/xor_i8.masm | 603 +++++++++++++++++++++++ tests/integration/expected/xor_u16.masm | 603 +++++++++++++++++++++++ tests/integration/expected/xor_u32.masm | 603 +++++++++++++++++++++++ tests/integration/expected/xor_u8.masm | 603 +++++++++++++++++++++++ 53 files changed, 31357 insertions(+) diff --git a/codegen/masm/src/masm/program.rs b/codegen/masm/src/masm/program.rs index 34dab1778..723118205 100644 --- a/codegen/masm/src/masm/program.rs +++ b/codegen/masm/src/masm/program.rs @@ -1,6 +1,7 @@ use core::fmt; use std::{collections::BTreeMap, path::Path, sync::Arc}; +use hir::Ident; use intrusive_collections::RBTree; use miden_hir::{self as hir, DataSegmentTable, FunctionIdent}; diff --git a/tests/integration/expected/and_bool.masm b/tests/integration/expected/and_bool.masm index e7b8fefb0..c53f30349 100644 --- a/tests/integration/expected/and_bool.masm +++ b/tests/integration/expected/and_bool.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.and diff --git a/tests/integration/expected/and_i16.masm b/tests/integration/expected/and_i16.masm index e7b8fefb0..c53f30349 100644 --- a/tests/integration/expected/and_i16.masm +++ b/tests/integration/expected/and_i16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.and diff --git a/tests/integration/expected/and_i32.masm b/tests/integration/expected/and_i32.masm index e7b8fefb0..c53f30349 100644 --- a/tests/integration/expected/and_i32.masm +++ b/tests/integration/expected/and_i32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.and diff --git a/tests/integration/expected/and_i8.masm b/tests/integration/expected/and_i8.masm index e7b8fefb0..c53f30349 100644 --- a/tests/integration/expected/and_i8.masm +++ b/tests/integration/expected/and_i8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.and diff --git a/tests/integration/expected/and_u16.masm b/tests/integration/expected/and_u16.masm index e7b8fefb0..c53f30349 100644 --- a/tests/integration/expected/and_u16.masm +++ b/tests/integration/expected/and_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.and diff --git a/tests/integration/expected/and_u32.masm b/tests/integration/expected/and_u32.masm index e7b8fefb0..c53f30349 100644 --- a/tests/integration/expected/and_u32.masm +++ b/tests/integration/expected/and_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.and diff --git a/tests/integration/expected/and_u8.masm b/tests/integration/expected/and_u8.masm index e7b8fefb0..c53f30349 100644 --- a/tests/integration/expected/and_u8.masm +++ b/tests/integration/expected/and_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.and diff --git a/tests/integration/expected/eq_i16.masm b/tests/integration/expected/eq_i16.masm index f46c685d7..42bf09176 100644 --- a/tests/integration/expected/eq_i16.masm +++ b/tests/integration/expected/eq_i16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.eq diff --git a/tests/integration/expected/eq_i32.masm b/tests/integration/expected/eq_i32.masm index f46c685d7..42bf09176 100644 --- a/tests/integration/expected/eq_i32.masm +++ b/tests/integration/expected/eq_i32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.eq diff --git a/tests/integration/expected/eq_i64.masm b/tests/integration/expected/eq_i64.masm index c7c006175..73b6154be 100644 --- a/tests/integration/expected/eq_i64.masm +++ b/tests/integration/expected/eq_i64.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint eqw diff --git a/tests/integration/expected/eq_i8.masm b/tests/integration/expected/eq_i8.masm index f46c685d7..42bf09176 100644 --- a/tests/integration/expected/eq_i8.masm +++ b/tests/integration/expected/eq_i8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.eq diff --git a/tests/integration/expected/eq_u16.masm b/tests/integration/expected/eq_u16.masm index f46c685d7..42bf09176 100644 --- a/tests/integration/expected/eq_u16.masm +++ b/tests/integration/expected/eq_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.eq diff --git a/tests/integration/expected/eq_u32.masm b/tests/integration/expected/eq_u32.masm index f46c685d7..42bf09176 100644 --- a/tests/integration/expected/eq_u32.masm +++ b/tests/integration/expected/eq_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.eq diff --git a/tests/integration/expected/eq_u64.masm b/tests/integration/expected/eq_u64.masm index c7c006175..73b6154be 100644 --- a/tests/integration/expected/eq_u64.masm +++ b/tests/integration/expected/eq_u64.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint eqw diff --git a/tests/integration/expected/eq_u8.masm b/tests/integration/expected/eq_u8.masm index f46c685d7..42bf09176 100644 --- a/tests/integration/expected/eq_u8.masm +++ b/tests/integration/expected/eq_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.eq diff --git a/tests/integration/expected/fib.masm b/tests/integration/expected/fib.masm index 1100271d9..397d65781 100644 --- a/tests/integration/expected/fib.masm +++ b/tests/integration/expected/fib.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.fib dup.0 push.2147483648 diff --git a/tests/integration/expected/ge_u16.masm b/tests/integration/expected/ge_u16.masm index 037659bcd..b2ce7f7c0 100644 --- a/tests/integration/expected/ge_u16.masm +++ b/tests/integration/expected/ge_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/ge_u32.masm b/tests/integration/expected/ge_u32.masm index 037659bcd..b2ce7f7c0 100644 --- a/tests/integration/expected/ge_u32.masm +++ b/tests/integration/expected/ge_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/ge_u8.masm b/tests/integration/expected/ge_u8.masm index 037659bcd..b2ce7f7c0 100644 --- a/tests/integration/expected/ge_u8.masm +++ b/tests/integration/expected/ge_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/gt_u16.masm b/tests/integration/expected/gt_u16.masm index 3b0966959..398b01e5c 100644 --- a/tests/integration/expected/gt_u16.masm +++ b/tests/integration/expected/gt_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/gt_u32.masm b/tests/integration/expected/gt_u32.masm index 3b0966959..398b01e5c 100644 --- a/tests/integration/expected/gt_u32.masm +++ b/tests/integration/expected/gt_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/gt_u8.masm b/tests/integration/expected/gt_u8.masm index 3b0966959..398b01e5c 100644 --- a/tests/integration/expected/gt_u8.masm +++ b/tests/integration/expected/gt_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/le_u16.masm b/tests/integration/expected/le_u16.masm index 8ec2001e7..350dcc97e 100644 --- a/tests/integration/expected/le_u16.masm +++ b/tests/integration/expected/le_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/le_u32.masm b/tests/integration/expected/le_u32.masm index 8ec2001e7..350dcc97e 100644 --- a/tests/integration/expected/le_u32.masm +++ b/tests/integration/expected/le_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/le_u8.masm b/tests/integration/expected/le_u8.masm index 8ec2001e7..350dcc97e 100644 --- a/tests/integration/expected/le_u8.masm +++ b/tests/integration/expected/le_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/lt_u16.masm b/tests/integration/expected/lt_u16.masm index 50abfa3f6..c00e184d1 100644 --- a/tests/integration/expected/lt_u16.masm +++ b/tests/integration/expected/lt_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/lt_u32.masm b/tests/integration/expected/lt_u32.masm index 50abfa3f6..c00e184d1 100644 --- a/tests/integration/expected/lt_u32.masm +++ b/tests/integration/expected/lt_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/lt_u8.masm b/tests/integration/expected/lt_u8.masm index 50abfa3f6..c00e184d1 100644 --- a/tests/integration/expected/lt_u8.masm +++ b/tests/integration/expected/lt_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/not_bool.masm b/tests/integration/expected/not_bool.masm index 153c428b9..51854593d 100644 --- a/tests/integration/expected/not_bool.masm +++ b/tests/integration/expected/not_bool.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint push.1 u32.xor diff --git a/tests/integration/expected/not_i16.masm b/tests/integration/expected/not_i16.masm index 50ecd2f6e..bb2e74145 100644 --- a/tests/integration/expected/not_i16.masm +++ b/tests/integration/expected/not_i16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint push.4294967295 u32.xor diff --git a/tests/integration/expected/not_i32.masm b/tests/integration/expected/not_i32.masm index 50ecd2f6e..bb2e74145 100644 --- a/tests/integration/expected/not_i32.masm +++ b/tests/integration/expected/not_i32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint push.4294967295 u32.xor diff --git a/tests/integration/expected/not_i8.masm b/tests/integration/expected/not_i8.masm index 50ecd2f6e..bb2e74145 100644 --- a/tests/integration/expected/not_i8.masm +++ b/tests/integration/expected/not_i8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint push.4294967295 u32.xor diff --git a/tests/integration/expected/not_u16.masm b/tests/integration/expected/not_u16.masm index 837aa43e3..b99dc8e1d 100644 --- a/tests/integration/expected/not_u16.masm +++ b/tests/integration/expected/not_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint push.65535 u32.xor diff --git a/tests/integration/expected/not_u32.masm b/tests/integration/expected/not_u32.masm index 50ecd2f6e..bb2e74145 100644 --- a/tests/integration/expected/not_u32.masm +++ b/tests/integration/expected/not_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint push.4294967295 u32.xor diff --git a/tests/integration/expected/not_u8.masm b/tests/integration/expected/not_u8.masm index 34580cc8e..18a1e3dd4 100644 --- a/tests/integration/expected/not_u8.masm +++ b/tests/integration/expected/not_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint push.255 u32.xor diff --git a/tests/integration/expected/or_bool.masm b/tests/integration/expected/or_bool.masm index a192a0ebd..eebe6de53 100644 --- a/tests/integration/expected/or_bool.masm +++ b/tests/integration/expected/or_bool.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.or diff --git a/tests/integration/expected/or_i16.masm b/tests/integration/expected/or_i16.masm index a192a0ebd..eebe6de53 100644 --- a/tests/integration/expected/or_i16.masm +++ b/tests/integration/expected/or_i16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.or diff --git a/tests/integration/expected/or_i32.masm b/tests/integration/expected/or_i32.masm index a192a0ebd..eebe6de53 100644 --- a/tests/integration/expected/or_i32.masm +++ b/tests/integration/expected/or_i32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.or diff --git a/tests/integration/expected/or_i8.masm b/tests/integration/expected/or_i8.masm index a192a0ebd..eebe6de53 100644 --- a/tests/integration/expected/or_i8.masm +++ b/tests/integration/expected/or_i8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.or diff --git a/tests/integration/expected/or_u16.masm b/tests/integration/expected/or_u16.masm index a192a0ebd..eebe6de53 100644 --- a/tests/integration/expected/or_u16.masm +++ b/tests/integration/expected/or_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.or diff --git a/tests/integration/expected/or_u32.masm b/tests/integration/expected/or_u32.masm index a192a0ebd..eebe6de53 100644 --- a/tests/integration/expected/or_u32.masm +++ b/tests/integration/expected/or_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.or diff --git a/tests/integration/expected/or_u8.masm b/tests/integration/expected/or_u8.masm index a192a0ebd..eebe6de53 100644 --- a/tests/integration/expected/or_u8.masm +++ b/tests/integration/expected/or_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.or diff --git a/tests/integration/expected/shr_u16.masm b/tests/integration/expected/shr_u16.masm index 36f480241..5a7735d27 100644 --- a/tests/integration/expected/shr_u16.masm +++ b/tests/integration/expected/shr_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/shr_u32.masm b/tests/integration/expected/shr_u32.masm index 9a341ef66..2b4493e10 100644 --- a/tests/integration/expected/shr_u32.masm +++ b/tests/integration/expected/shr_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/shr_u8.masm b/tests/integration/expected/shr_u8.masm index 555253a69..1e7dc45b6 100644 --- a/tests/integration/expected/shr_u8.masm +++ b/tests/integration/expected/shr_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint dup.0 push.2147483648 diff --git a/tests/integration/expected/xor_bool.masm b/tests/integration/expected/xor_bool.masm index b3916b649..cc2717c9a 100644 --- a/tests/integration/expected/xor_bool.masm +++ b/tests/integration/expected/xor_bool.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.xor diff --git a/tests/integration/expected/xor_i16.masm b/tests/integration/expected/xor_i16.masm index b3916b649..cc2717c9a 100644 --- a/tests/integration/expected/xor_i16.masm +++ b/tests/integration/expected/xor_i16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.xor diff --git a/tests/integration/expected/xor_i32.masm b/tests/integration/expected/xor_i32.masm index b3916b649..cc2717c9a 100644 --- a/tests/integration/expected/xor_i32.masm +++ b/tests/integration/expected/xor_i32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.xor diff --git a/tests/integration/expected/xor_i8.masm b/tests/integration/expected/xor_i8.masm index b3916b649..cc2717c9a 100644 --- a/tests/integration/expected/xor_i8.masm +++ b/tests/integration/expected/xor_i8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.xor diff --git a/tests/integration/expected/xor_u16.masm b/tests/integration/expected/xor_u16.masm index b3916b649..cc2717c9a 100644 --- a/tests/integration/expected/xor_u16.masm +++ b/tests/integration/expected/xor_u16.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.xor diff --git a/tests/integration/expected/xor_u32.masm b/tests/integration/expected/xor_u32.masm index b3916b649..cc2717c9a 100644 --- a/tests/integration/expected/xor_u32.masm +++ b/tests/integration/expected/xor_u32.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.xor diff --git a/tests/integration/expected/xor_u8.masm b/tests/integration/expected/xor_u8.masm index b3916b649..cc2717c9a 100644 --- a/tests/integration/expected/xor_u8.masm +++ b/tests/integration/expected/xor_u8.masm @@ -1,3 +1,606 @@ +export.is_signed + push.2147483648 + u32.and + push.2147483648 + eq + +end + +export.overflowing_add + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.add.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_add + exec.overflowing_add + assertz + +end + +export.checked_neg + dup.0 + push.2147483648 + eq + assertz + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_neg + u32.not + u32.add.wrapping.1 + +end + +export.unchecked_sub + u32.not + add + incr + +end + +export.overflowing_sub + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.sub.wrapping + dup.0 + exec.is_signed + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_sub + exec.overflowing_sub + assertz + +end + +export.overflowing_mul + u32.assert2 + dup.0 + exec.is_signed + dup.2 + exec.is_signed + movup.3 + movup.3 + u32.mul.wrapping + movup.3 + dup.1 + eq + swap.1 + movup.3 + neq + and + +end + +export.checked_mul + exec.overflowing_mul + assertz + +end + +export.checked_div + u32.assert2 + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + dup.1 + exec.unchecked_neg + dup.2 + swap.1 + movup.3 + exec.is_signed + dup.0 + movdn.4 + cdrop + u32.div.unchecked + movdn.2 + neq + dup.1 + exec.unchecked_neg + swap.1 + cdrop + +end + +export.icmp + dup.1 + dup.1 + push.2147483648 + u32.and + swap.1 + push.2147483648 + u32.and + eq.0 + swap.1 + eq.0 + swap.1 + dup.1 + neq + if.true + movdn.2 + drop + drop + push.1 + push.4294967295 + swap.2 + cdrop + else + drop + dup.1 + dup.1 + u32.gt.unchecked + movdn.2 + u32.lt.unchecked + push.0 + push.4294967295 + push.1 + swap.3 + cdrop + swap.2 + cdrop + end + +end + +export.is_lt + exec.icmp + push.4294967295 + eq + +end + +export.is_lte + exec.icmp + neq.1 + +end + +export.is_gt + exec.icmp + eq.1 + +end + +export.is_gte + exec.icmp + push.4294967295 + neq + +end + +export.pow2 + dup.0 + push.31 + u32.lt.checked + assert + push.1 + swap.1 + u32.shl.checked + +end + +export.ipow + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + push.1 + push.0 + swap.2 + cdrop + swap.1 + drop + else + push.1 + dup.1 + push.1 + u32.gt.checked + while.true + dup.2 + dup.1 + mul + dup.2 + push.1 + u32.and + eq.1 + cdrop + u32.assert + swap.1 + u32.div.checked.2 + movup.2 + dup.0 + u32.mul.checked + swap.1 + movup.2 + dup.1 + push.1 + u32.gt.checked + end + swap.1 + drop + u32.mul.checked + end + +end + +export.checked_shr + dup.0 + push.32 + u32.lt.checked + assert + dup.0 + eq.0 + dup.2 + eq.0 + or + if.true + eq.0 + swap.1 + push.0 + swap.2 + cdrop + else + dup.1 + push.2147483648 + u32.and + push.2147483648 + eq + if.true + swap.1 + dup.1 + u32.shr.checked + push.1 + dup.2 + u32.shl.unchecked + sub.1 + push.32 + movup.3 + sub + u32.shl.unchecked + u32.or + else + u32.shr.checked + end + end + +end + +export.extract_element + dup.0 + push.3 + lte + assert + dup.0 + push.3 + lt + movdn.5 + dup.0 + push.2 + lt + movdn.5 + push.1 + lt + cdrop + movup.3 + cdrop + movup.2 + cdrop + +end + +proc.load_felt_unchecked + padw + movup.4 + mem_loadw + movup.4 + exec.extract_element + +end + +export.load_felt + movup.2 + assertz + exec.load_felt_unchecked + +end + +export.load_sw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + exec.load_felt_unchecked + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.3 + movup.3 + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movdn.2 + movdn.2 + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + dup.2 + u32.shl.checked + swap.1 + push.32 + movup.3 + u32.sub.checked + u32.shr.checked + u32.or + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movdn.4 + drop + drop + drop + push.32 + dup.3 + u32.sub.checked + u32.shr.checked + swap.1 + padw + movup.4 + mem_loadw + drop + drop + drop + movup.2 + u32.shl.checked + u32.or + end + end + end + end + +end + +export.realign_dw + dup.3 + u32.shl.checked + movdn.2 + dup.0 + push.32 + dup.4 + u32.shr.checked + movup.4 + u32.or + movdn.2 + dup.3 + u32.shl.checked + swap.1 + push.32 + movup.4 + u32.shr.checked + u32.or + swap.1 + +end + +export.load_dw + dup.2 + eq.0 + dup.3 + push.8 + u32.lt.checked + assert + if.true + movup.2 + drop + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + movup.3 + drop + else + swap.1 + eq.2 + if.true + padw + movup.4 + mem_loadw + drop + drop + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + movup.4 + padw + movup.4 + mem_loadw + drop + drop + drop + end + end + end + else + dup.1 + eq.0 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + movup.4 + drop + exec.realign_dw + else + dup.1 + eq.1 + if.true + swap.1 + drop + padw + movup.4 + mem_loadw + drop + exec.realign_dw + else + swap.1 + eq.2 + if.true + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + movup.4 + drop + drop + drop + swap.1 + padw + movup.4 + mem_loadw + drop + drop + exec.realign_dw + else + dup.0 + u32.add.checked.1 + padw + movup.4 + mem_loadw + movup.4 + movup.4 + drop + drop + movup.2 + padw + movup.4 + mem_loadw + drop + drop + drop + exec.realign_dw + end + end + end + end + +end + export.entrypoint u32.xor