From 03ea496c643ab36e4f685b6de8ac2c491de3fcea Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Fri, 17 Nov 2023 21:25:56 -0500 Subject: [PATCH 1/3] chore: update miden-assembly to next --- Cargo.lock | 55 +- Cargo.toml | 8 +- codegen/masm/intrinsics/i32.masm | 44 +- codegen/masm/intrinsics/mem.masm | 60 +- codegen/masm/src/emulator/functions.rs | 10 +- codegen/masm/src/emulator/mod.rs | 155 +----- codegen/masm/src/masm/module.rs | 35 +- codegen/masm/src/stackify/emit/binary.rs | 105 ++-- codegen/masm/src/stackify/emit/int32.rs | 104 ++-- codegen/masm/src/stackify/emit/int64.rs | 2 +- codegen/masm/src/stackify/emit/mem.rs | 48 +- codegen/masm/src/stackify/emit/smallint.rs | 4 +- codegen/masm/src/stackify/emit/unary.rs | 14 +- hir/Cargo.toml | 2 +- hir/src/asm/builder.rs | 603 +++++++++++---------- hir/src/asm/display.rs | 46 +- hir/src/asm/isa.rs | 588 +++++++++----------- hir/src/immediates.rs | 24 + 18 files changed, 874 insertions(+), 1033 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 386069213..460b6ddf2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -817,9 +817,8 @@ dependencies = [ [[package]] name = "miden-air" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5fa086b50e9fc3f808e171cb69f81fe464efbc01f996df3db0e450caaf070749" +version = "0.8.0" +source = "git+https://github.com/0xPolygonMiden/miden-vm?branch=next#ed0e87019fd1354b782cfab9bfbe5daa183a4e16" dependencies = [ "miden-core", "winter-air", @@ -827,9 +826,8 @@ dependencies = [ [[package]] name = "miden-assembly" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c483ade3de7375f869a2c99de2396d0545cb6df96e0e96d693a40e298b4cfea" +version = "0.8.0" +source = "git+https://github.com/0xPolygonMiden/miden-vm?branch=next#ed0e87019fd1354b782cfab9bfbe5daa183a4e16" dependencies = [ "miden-core", "num_enum", @@ -859,9 +857,8 @@ dependencies = [ [[package]] name = "miden-core" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3baf9ff16e3f7a6c045c8ece8d2d7ebf4521eab92de07cc9edb11f3e9c853143" +version = "0.8.0" +source = "git+https://github.com/0xPolygonMiden/miden-vm?branch=next#ed0e87019fd1354b782cfab9bfbe5daa183a4e16" dependencies = [ "miden-crypto", "winter-crypto", @@ -871,9 +868,8 @@ dependencies = [ [[package]] name = "miden-crypto" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "32dd571edafdd5e8947e4006a905a1c5373f2f8b08b270fea3c998db5be131cf" +version = "0.8.0" +source = "git+https://github.com/0xPolygonMiden/crypto?branch=next#9f0aaf626bea4f676738eb9d4f80472f258a0399" dependencies = [ "blake3", "cc", @@ -1056,9 +1052,8 @@ dependencies = [ [[package]] name = "miden-processor" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229cd9564e22c81d0d0122377c248f07e4e85706d566c778d65a53b8005fcda6" +version = "0.8.0" +source = "git+https://github.com/0xPolygonMiden/miden-vm?branch=next#ed0e87019fd1354b782cfab9bfbe5daa183a4e16" dependencies = [ "log", "miden-air", @@ -1068,9 +1063,8 @@ dependencies = [ [[package]] name = "miden-stdlib" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a6deebc865ae05b19e130644fd52051cbd591f024edc2920fdd7b66d4fc8198" +version = "0.8.0" +source = "git+https://github.com/0xPolygonMiden/miden-vm?branch=next#ed0e87019fd1354b782cfab9bfbe5daa183a4e16" dependencies = [ "miden-assembly", ] @@ -2025,10 +2019,11 @@ dependencies = [ [[package]] name = "winter-air" -version = "0.6.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e952a5774c8e5d13cc015f29351f7f76511ce41440aa39d01c12365bb70e285e" +checksum = "5f005354ab46d1b3f7340cf174063eb330eb6f6ec6d08c6c4138d02ed8fb8a1f" dependencies = [ + "libm", "winter-crypto", "winter-fri", "winter-math", @@ -2037,9 +2032,9 @@ dependencies = [ [[package]] name = "winter-crypto" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54a20b2a4499797cbaeb38c980f9f34e6e60d993e8e170a6deb354345f50cbfb" +checksum = "9d832015262e7d8ce6c160d3c8eb52e3a1c1352a7760523a25c4094c5d250cb9" dependencies = [ "blake3", "sha3", @@ -2049,9 +2044,9 @@ dependencies = [ [[package]] name = "winter-fri" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60de4e8baf33cc388b82f79808e42dacd7cb208e8c17bd10e3f8b8bdbdae1668" +checksum = "23a218e3e37f316b933790f58298344b2ba94941fc7b5cc28adb2be6a9d4a959" dependencies = [ "winter-crypto", "winter-math", @@ -2060,18 +2055,18 @@ dependencies = [ [[package]] name = "winter-math" -version = "0.6.5" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1795f5323f03c987a6aada6e8229f2c7f9353956cfa1b648b9c6cf5440958caa" +checksum = "9f51c43e0756c89607b74a2da621ca472306bfb1ecc352a44a97dfe73cd0503d" dependencies = [ "winter-utils", ] [[package]] name = "winter-prover" -version = "0.6.4" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2adea1eb4620fd1b3e8a7647a2a45bd4ebcab4cda14c9719b70039db05762191" +checksum = "9dd3744a539c4b9f92ba43123a5eed5b0f6402204f92c6a3187de30189693e7b" dependencies = [ "log", "winter-air", @@ -2083,9 +2078,9 @@ dependencies = [ [[package]] name = "winter-utils" -version = "0.6.4" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b903fda6a50cce2aa5a172a9269aca0f09b25df20afb1faa427db76d40779671" +checksum = "9e914055793322b3efa7ea6acd5116edf65aebcb704a09b1c4d1308c82509992" [[package]] name = "yansi" diff --git a/Cargo.toml b/Cargo.toml index c3faecfec..61e683656 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,10 +59,10 @@ smallvec = { version = "1.9", features = [ smallstr = { version = "0.3", features = ["union"] } thiserror = "1.0" toml = { version = "0.5", features = ["preserve_order"] } -miden-assembly = "0.7" -miden-core = "0.7" -miden-processor = "0.7" -miden-stdlib = "0.6" +miden-assembly = { git = "https://github.com/0xPolygonMiden/miden-vm", branch = "next" } +miden-core = { git = "https://github.com/0xPolygonMiden/miden-vm", branch = "next" } +miden-processor = { git = "https://github.com/0xPolygonMiden/miden-vm", branch = "next" } +miden-stdlib = { git = "https://github.com/0xPolygonMiden/miden-vm", branch = "next" } miden-codegen-masm = { path = "codegen/masm" } miden-diagnostics = "0.1" miden-hir = { path = "hir" } diff --git a/codegen/masm/intrinsics/i32.masm b/codegen/masm/intrinsics/i32.masm index 2980557bb..ae259c104 100644 --- a/codegen/masm/intrinsics/i32.masm +++ b/codegen/masm/intrinsics/i32.masm @@ -7,14 +7,14 @@ const.NEG1=4294967295 # u32::MAX # # This function consumes `a`. export.is_signed # [a] - push.SIGN_BIT u32checked_and push.SIGN_BIT eq + push.SIGN_BIT u32and push.SIGN_BIT eq end # Get the negation of `a` # # This operation is unchecked, so if the input is not a valid i32 the behavior is undefined export.unchecked_neg # [a] - u32checked_not u32wrapping_add.1 + u32not u32wrapping_add.1 end # Get the negation of `a` @@ -214,7 +214,7 @@ export.checked_div # [b, a] dup.0 movdn.5 cdrop # [|b|, |a|, is_a_signed, is_b_signed] # divide - u32unchecked_div # [|a / b|, is_a_signed, is_b_signed] + u32div # [|a / b|, is_a_signed, is_b_signed] # if the signs differ, negate the result movdn.2 neq # [signs_differ, |a / b|] @@ -230,12 +230,12 @@ export.icmp # [b, a] # get the most-significant bit of `b` push.SIGN_BIT # [1<<31, b, a, b, a] - u32checked_and # [b_msb, a, b, a] + u32and # [b_msb, a, b, a] # get the most-significant bit of `a` swap.1 # [a, b_msb, b, a] push.SIGN_BIT # [1<<31, a, b_msb, b, a] - u32checked_and # [a_msb, b_msb, b, a] + u32and # [a_msb, b_msb, b, a] eq.0 # [a_msb == 0, b_msb, b, a] swap.1 eq.0 # [b_msb == 0, a_msb == 0, b, a] @@ -252,8 +252,8 @@ export.icmp # [b, a] # which we get for free via the lt/gt ops drop # [b, a] dup.1 dup.1 # [b, a, b, a] - u32unchecked_gt movdn.2 # [b, a, a > b] - u32unchecked_lt # [a < b, a > b] + u32gt movdn.2 # [b, a, a > b] + u32lt # [a < b, a > b] push.0 push.NEG1 push.1 swap.3 # [a < b, -1, 0, 1, a > b] cdrop # [-1 or 0, 1, a > b] @@ -286,15 +286,15 @@ end export.pow2 # [n] dup.0 push.31 - u32checked_lt # [n < 31, pow] + u32lt # [n < 31, pow] assert # [n] push.1 swap.1 # [n, 1] - u32checked_shl # [1 << n] + u32shl # [1 << n] end # Compute a^b, where `b` must be a positive i32 value < 31 export.ipow # [b, a] - dup.0 push.31 u32checked_lt assert # assert that `b` is < 31 + dup.0 push.31 u32lt assert # assert that `b` is < 31 dup.0 eq.0 # [b == 0, b, a] dup.2 eq.0 # [a == 0, b == 0, b, a] or # [a == 0 || b == 0, b, a] @@ -310,23 +310,23 @@ export.ipow # [b, a] push.1 # [acc, b, a] dup.1 # [b, acc, b, a] push.1 # [1, b, acc, b, a] - u32checked_gt # [b > 1, acc, b, a] + u32gt # [b > 1, acc, b, a] while.true # [acc, b, a => base] dup.2 dup.1 # [acc, base, acc, b, base] u32wrapping_mul # [base * acc, acc, b, base] dup.2 # [b, base * acc, acc, b, base] push.1 # [1, b, base * acc, acc, b, base] - u32checked_and # [b & 1, base * acc, acc, b, base] + u32and # [b & 1, base * acc, acc, b, base] eq.1 # [b & 1 == 1, base * acc, acc, b, base] cdrop # [acc, b, base] swap.1 # [b, acc, base] - u32checked_div.2 # [b /= 2, acc, base] + u32div.2 # [b /= 2, acc, base] movup.2 dup.0 # [base, base, b, acc] u32wrapping_mul # [base * base, b, acc] swap.1 # [b, base, acc] movup.2 # [acc, b, base] dup.1 push.1 # [1, b, acc, b, base] - u32checked_gt # [b > 1, acc, b, base] + u32gt # [b > 1, acc, b, base] end swap.1 drop # [acc, base] u32wrapping_mul # [acc * base] @@ -341,7 +341,7 @@ end export.checked_shr # [b, a] # validate the shift is valid dup.0 push.32 - u32checked_lt # [b < 32, b, a] + u32lt # [b < 32, b, a] assert # if the input is zero, the output is always zero, @@ -359,27 +359,29 @@ export.checked_shr # [b, a] # get the signedness of the value dup.1 # [a, b, a] push.SIGN_BIT # [1<<31, a, b, a] - u32checked_and push.SIGN_BIT eq # [is_signed, b, a] + u32and push.SIGN_BIT eq # [is_signed, b, a] # if the value is signed, we must sign-extend the result, # otherwise we can treat it as an unsigned shift if.true # [b, a] swap.1 # [a, b] dup.1 # [b, a, b] - u32checked_shr # [shifted, b] + u32shr # [shifted, b] # compute the extension mask push.1 dup.2 # [b, 1, shifted, b] - u32unchecked_shl + u32shl sub.1 # [(1 << b) - 1, shifted, b] # shift the mask into place push.32 movup.3 # [b, 32, mask, shifted] sub # [32 - b, mask, shifted] - u32unchecked_shl # [mask << (32 - b), shifted] - u32checked_or # [shifted | mask] + u32shl # [mask << (32 - b), shifted] + u32or # [shifted | mask] + u32assert else - u32checked_shr + u32shr + u32assert end end end diff --git a/codegen/masm/intrinsics/mem.masm b/codegen/masm/intrinsics/mem.masm index 8ead2d202..6b7e86831 100644 --- a/codegen/masm/intrinsics/mem.masm +++ b/codegen/masm/intrinsics/mem.masm @@ -59,7 +59,7 @@ end export.load_sw # [waddr, index, offset] # check for alignment and offset validity dup.2 eq.0 - dup.3 push.8 u32checked_lt assert # offset must be < 8 + dup.3 push.8 u32lt assert # offset must be < 8 # if the pointer is naturally aligned.. if.true # drop the byte offset @@ -78,13 +78,13 @@ export.load_sw # [waddr, index, offset] # drop the unused elements movup.3 movup.3 drop drop # shift high bits left by the offset - dup.2 u32checked_shl # [hi, w1, offset] + dup.2 u32shl # [hi, w1, offset] # move the low bits to the top and shift them as well swap.1 push.32 movup.3 # [offset, 32, w1, hi] - u32checked_sub # [32 - offset, w1, hi] - u32checked_shr # [lo, hi] + u32overflowing_sub assertz # [32 - offset, w1, hi] + u32shr # [lo, hi] # combine the two halves - u32checked_or # [result] + u32or # [result] else # check if the load starts in the second element dup.1 eq.1 @@ -97,13 +97,13 @@ export.load_sw # [waddr, index, offset] # drop the unused elements drop movdn.2 movdn.2 drop # [w1, w2, offset] # shift the high bits - dup.2 u32checked_shl # [hi, w2, offset] + dup.2 u32shl # [hi, w2, offset] # shift the low bits - swap.1 push.32 movup.3 # [offset, 32, w2, hi] - u32checked_sub # [32 - offset, w2, hi] - u32checked_shr # [lo, hi] + swap.1 push.32 movup.3 # [offset, 32, w2, hi] + u32overflowing_sub assertz # [32 - offset, w2, hi] + u32shr # [lo, hi] # combine the two halves - u32checked_or # [result] + u32or # [result] else # check if the load starts in the third element swap.1 eq.2 @@ -113,30 +113,30 @@ export.load_sw # [waddr, index, offset] # drop first two unused drop drop # [w2, w3, offset] # shift the high bits - dup.2 u32checked_shl # [hi, w3, offset] + dup.2 u32shl # [hi, w3, offset] # shift the low bits - swap.1 push.32 movup.3 # [offset, 32, w3, hi] - u32checked_sub # [32 - offset, w3, hi] - u32checked_shr # [lo, hi] + swap.1 push.32 movup.3 # [offset, 32, w3, hi] + u32overflowing_sub assertz # [32 - offset, w3, hi] + u32shr # [lo, hi] # combine the two halves - u32checked_or # [result] + u32or # [result] else # the load crosses a word boundary # start with the word containing the low bits dup.0 # [waddr, waddr, offset] - u32checked_add.1 # [waddr + 1, waddr, offset] + u32overflowing_add.1 assertz # [waddr + 1, waddr, offset] # load the word and drop the unused elements padw movup.4 mem_loadw movdn.4 drop drop drop # [w0, waddr, offset] # shift the low bits push.32 dup.3 # [offset, 32, w0, waddr, offset] - u32checked_sub # [32 - offset, w0, waddr, offset] - u32checked_shr # [lo, waddr, offset] + u32overflowing_sub assertz # [32 - offset, w0, waddr, offset] + u32shr # [lo, waddr, offset] # load the word with the high bits, drop unused elements swap.1 padw movup.4 mem_loadw drop drop drop # [w3, lo, offset] # shift high bits - movup.2 u32checked_shl # [hi, lo] + movup.2 u32shl # [hi, lo] # combine the two halves - u32checked_or # [result] + u32or # [result] end end end @@ -191,7 +191,7 @@ export.realign_dw # [chunk_hi, chunk_mid, chunk_lo, offset] # Re-align the high bits by shifting out the offset # # This gives us the first half of the first word. - dup.3 u32checked_shl # [x_hi_hi, chunk_mid, chunk__lo, offset] + dup.3 u32shl # [x_hi_hi, chunk_mid, chunk__lo, offset] # Move the value below the other chunks temporarily movdn.2 # [chunk_mid, chunk_lo, x_hi_hi, offset] @@ -209,7 +209,7 @@ export.realign_dw # [chunk_hi, chunk_mid, chunk_lo, offset] # Then, we shift the chunk right by 32 - offset bits, # re-aligning the low bits of the first word, and # isolating them. - push.32 dup.4 u32checked_shr # [x_hi_lo, chunk_mid, chunk_lo, offset, x_hi_hi] + push.32 dup.4 u32shr # [x_hi_lo, chunk_mid, chunk_lo, offset, x_hi_hi] # Move the high bits back to the top # @@ -217,7 +217,7 @@ export.realign_dw # [chunk_hi, chunk_mid, chunk_lo, offset] movup.4 # [x_hi_hi, x_hi_lo, chunk_mid, chunk_lo, offset] # OR the two parts of the `x_hi` chunk together - u32checked_or # [x_hi, chunk_mid, chunk_lo, offset] + u32or # [x_hi, chunk_mid, chunk_lo, offset] # Move `x_hi` to the bottom for later movdn.2 # [chunk_mid, chunk_lo, x_hi, offset] @@ -229,16 +229,16 @@ export.realign_dw # [chunk_hi, chunk_mid, chunk_lo, offset] # This gives us the first half of the second word. # # [x_lo_hi, chunk_lo, x_hi] - dup.3 u32checked_shl # [x_lo_hi, chunk_lo, x_hi, offset] + dup.3 u32shl # [x_lo_hi, chunk_lo, x_hi, offset] # Next, swap the low bit chunk to the top temporarily swap.1 # Shift the value right, as done previously for the middle chunk - push.32 movup.4 u32checked_shr # [x_lo_lo, x_lo_hi, x_hi] + push.32 movup.4 u32shr # [x_lo_lo, x_lo_hi, x_hi] # OR the two halves together, giving us our second word, `x_lo` - u32checked_or # [x_lo, x_hi] + u32or # [x_lo, x_hi] # Swap the words so they are in the correct order swap.1 # [x_hi, x_lo] @@ -249,7 +249,7 @@ end export.load_dw # [waddr, index, offset] # check for alignment and offset validity dup.2 eq.0 - dup.3 push.8 u32checked_lt assert # offset must be < 8 + dup.3 push.8 u32lt assert # offset must be < 8 # if the pointer is naturally aligned.. if.true # drop byte offset @@ -279,7 +279,7 @@ export.load_dw # [waddr, index, offset] padw movup.4 mem_loadw drop drop else # load first element of next word, drop the rest - dup.0 u32checked_add.1 padw movup.4 mem_loadw + dup.0 u32overflowing_add.1 assertz padw movup.4 mem_loadw movup.4 movup.4 movup.4 drop drop drop # load fourth element, and we're done @@ -312,7 +312,7 @@ export.load_dw # [waddr, index, offset] swap.1 eq.2 if.true # load one element from the next word - dup.0 u32checked_add.1 padw movup.4 mem_loadw + dup.0 u32overflowing_add.1 assertz padw movup.4 mem_loadw movup.4 movup.4 movup.4 drop drop drop # load two elements from the first word swap.1 padw movup.4 mem_loadw drop drop @@ -320,7 +320,7 @@ export.load_dw # [waddr, index, offset] exec.realign_dw else # load the two least-significant elements from the next word first - dup.0 u32checked_add.1 padw movup.4 mem_loadw + dup.0 u32overflowing_add.1 assertz padw movup.4 mem_loadw movup.4 movup.4 drop drop # load the most significant element from the first word movup.2 padw movup.4 mem_loadw drop drop drop diff --git a/codegen/masm/src/emulator/functions.rs b/codegen/masm/src/emulator/functions.rs index b2f9b27eb..d60e20b13 100644 --- a/codegen/masm/src/emulator/functions.rs +++ b/codegen/masm/src/emulator/functions.rs @@ -650,7 +650,7 @@ mod tests { assert_eq!( activation.peek_with_op(), Some(InstructionWithOp { - op: Op::U32UncheckedLt, + op: Op::U32Lt, continuing_from: None, ip: InstructionPointer { block: loop_body, @@ -661,7 +661,7 @@ mod tests { ); // Advance the instruction pointer, obtaining the last instruction of the loop body - assert_eq!(activation.next().map(|ix| ix.op), Some(Op::U32UncheckedLt)); + assert_eq!(activation.next().map(|ix| ix.op), Some(Op::U32Lt)); // Exit while.true assert_eq!( @@ -746,7 +746,7 @@ mod tests { body.push(Op::PushU8(1)); body.push(Op::Dup(1)); body.push(Op::Dup(1)); - body.push(Op::U32UncheckedLt); + body.push(Op::U32Lt); body.push(Op::If(then_blk, else_blk)); body.push(Op::Exec("test::foo".parse().unwrap())); } @@ -757,14 +757,14 @@ mod tests { } { let else_body = function.block_mut(else_blk); - else_body.push(Op::U32UncheckedMax); + else_body.push(Op::U32Max); } { let while_body = function.block_mut(while_blk); while_body.push(Op::Dup(1)); while_body.push(Op::Dup(1)); while_body.push(Op::Incr); - while_body.push(Op::U32UncheckedLt); + while_body.push(Op::U32Lt); } Arc::new(function) diff --git a/codegen/masm/src/emulator/mod.rs b/codegen/masm/src/emulator/mod.rs index a96d50a0d..4b16ffffc 100644 --- a/codegen/masm/src/emulator/mod.rs +++ b/codegen/masm/src/emulator/mod.rs @@ -897,48 +897,6 @@ macro_rules! binop_unchecked_u32 { }}; } -/// Applies a checked binary operator to two u32 values, either: -/// -/// 1. The top two elements of the stack -/// 2. The top element of the stack and an immediate. -macro_rules! binop_checked_u32 { - ($emu:ident, $op:ident) => {{ - paste::paste! { - binop_checked_u32_impl!($emu, []); - } - }}; - - ($emu:ident, $op:ident, $imm:expr) => {{ - paste::paste! { - binop_checked_u32_impl!($emu, [], $imm); - } - }}; -} - -#[doc(hidden)] -macro_rules! binop_checked_u32_impl { - ($emu:ident, $op:ident) => {{ - #[allow(unused)] - use core::ops::*; - let b = pop_u32!($emu); - let a = pop_u32!($emu); - let result = a - .$op(b) - .expect("checked operation failed: result has overflowed the u32 range"); - $emu.stack.push(Felt::new(result as u64)); - }}; - - ($emu:ident, $op:ident, $imm:expr) => {{ - #[allow(unused)] - use core::ops::*; - let a = pop_u32!($emu); - let result = a - .$op($imm) - .expect("checked operation failed: result has overflowed the u32 range"); - $emu.stack.push(Felt::new(result as u64)); - }}; -} - /// Applies an overflowing binary operator to two u32 values, either: /// /// 1. The top two elements of the stack @@ -1034,25 +992,6 @@ macro_rules! comparison { }}; } -/// Applies a binary comparison operator to two u32 values, either: -/// -/// 1. The top two elements of the stack -/// 2. The top element of the stack and an immediate. -macro_rules! comparison32 { - ($emu:ident, $op:ident) => {{ - let b = pop_u32!($emu); - let a = pop_u32!($emu); - let result: bool = a.$op(&b); - $emu.stack.push_u8(result as u8); - }}; - - ($emu:ident, $op:ident, $imm:expr) => {{ - let a = pop_u32!($emu); - let result: bool = a.$op(&$imm); - $emu.stack.push_u8(result as u8); - }}; -} - impl Emulator { /// Step the emulator forward one cycle, returning the type of event produced /// during that cycle, or an error. @@ -1654,22 +1593,16 @@ impl Emulator { self.stack.push(Felt::new(lo)); self.stack.push(Felt::new(hi)); } - Op::U32CheckedAdd => binop_checked_u32!(self, add), - Op::U32CheckedAddImm(imm) => binop_checked_u32!(self, add, imm), Op::U32OverflowingAdd => binop_overflowing_u32!(self, add), Op::U32OverflowingAddImm(imm) => binop_overflowing_u32!(self, add, imm), Op::U32WrappingAdd => binop_wrapping_u32!(self, add), Op::U32WrappingAddImm(imm) => binop_wrapping_u32!(self, add, imm), Op::U32OverflowingAdd3 => todo!(), Op::U32WrappingAdd3 => todo!(), - Op::U32CheckedSub => binop_checked_u32!(self, sub), - Op::U32CheckedSubImm(imm) => binop_checked_u32!(self, sub, imm), Op::U32OverflowingSub => binop_overflowing_u32!(self, sub), Op::U32OverflowingSubImm(imm) => binop_overflowing_u32!(self, sub, imm), Op::U32WrappingSub => binop_wrapping_u32!(self, sub), Op::U32WrappingSubImm(imm) => binop_wrapping_u32!(self, sub, imm), - Op::U32CheckedMul => binop_checked_u32!(self, mul), - Op::U32CheckedMulImm(imm) => binop_checked_u32!(self, mul, imm), Op::U32OverflowingMul => binop_overflowing_u32!(self, mul), Op::U32OverflowingMulImm(imm) => binop_overflowing_u32!(self, mul, imm), Op::U32WrappingMul => binop_wrapping_u32!(self, mul), @@ -1691,39 +1624,24 @@ impl Emulator { let d = (a * b + c) % 2u64.pow(32); self.stack.push(Felt::new(d)); } - Op::U32CheckedDiv => binop_checked_u32!(self, div), - Op::U32CheckedDivImm(imm) => binop_checked_u32!(self, div, imm), - Op::U32UncheckedDiv => binop_unchecked_u32!(self, div), - Op::U32UncheckedDivImm(imm) => binop_unchecked_u32!(self, div, imm as u64), - Op::U32CheckedMod => binop_checked_u32!(self, rem), - Op::U32CheckedModImm(imm) => binop_checked_u32!(self, rem, imm), - Op::U32UncheckedMod => { + Op::U32Div => binop_unchecked_u32!(self, div), + Op::U32DivImm(imm) => binop_unchecked_u32!(self, div, imm as u64), + Op::U32Mod => { let b = pop!(self).as_int(); let a = pop!(self).as_int(); self.stack.push(Felt::new(a % b)); } - Op::U32UncheckedModImm(imm) => { + Op::U32ModImm(imm) => { let a = pop!(self).as_int(); self.stack.push(Felt::new(a % imm as u64)); } - Op::U32CheckedDivMod => { - let b = pop_u32!(self); - let a = pop_u32!(self); - self.stack.push_u32(a / b); - self.stack.push_u32(a % b); - } - Op::U32CheckedDivModImm(imm) => { - let a = pop_u32!(self); - self.stack.push_u32(a / imm); - self.stack.push_u32(a % imm); - } - Op::U32UncheckedDivMod => { + Op::U32DivMod => { let b = pop!(self).as_int(); let a = pop!(self).as_int(); self.stack.push(Felt::new(a / b)); self.stack.push(Felt::new(a % b)); } - Op::U32UncheckedDivModImm(b) => { + Op::U32DivModImm(b) => { let b = b as u64; let a = pop!(self).as_int(); self.stack.push(Felt::new(a / b)); @@ -1736,76 +1654,47 @@ impl Emulator { let a = pop_u32!(self); self.stack.push_u32(!a); } - Op::U32CheckedShl => binop_checked_u32!(self, shl), - Op::U32CheckedShlImm(imm) => binop_checked_u32!(self, shl, imm), - Op::U32UncheckedShl => binop_wrapping_u32!(self, shl), - Op::U32UncheckedShlImm(imm) => binop_wrapping_u32!(self, shl, imm), - Op::U32CheckedShr => binop_checked_u32!(self, shr), - Op::U32CheckedShrImm(imm) => binop_checked_u32!(self, shr, imm), - Op::U32UncheckedShr => binop_wrapping_u32!(self, shr), - Op::U32UncheckedShrImm(imm) => binop_wrapping_u32!(self, shr, imm), - Op::U32CheckedRotl => binop32!(self, rotate_left), - Op::U32CheckedRotlImm(imm) => binop32!(self, rotate_left, imm), - Op::U32UncheckedRotl => { + Op::U32Shl => binop_wrapping_u32!(self, shl), + Op::U32ShlImm(imm) => binop_wrapping_u32!(self, shl, imm), + Op::U32Shr => binop_wrapping_u32!(self, shr), + Op::U32ShrImm(imm) => binop_wrapping_u32!(self, shr, imm), + Op::U32Rotl => { let b = pop_u32!(self); let a = pop!(self).as_int(); self.stack.push(Felt::new(a.rotate_left(b))); } - Op::U32UncheckedRotlImm(imm) => { + Op::U32RotlImm(imm) => { let a = pop!(self).as_int(); self.stack.push(Felt::new(a.rotate_left(imm))); } - Op::U32CheckedRotr => binop32!(self, rotate_right), - Op::U32CheckedRotrImm(imm) => binop32!(self, rotate_right, imm), - Op::U32UncheckedRotr => { + Op::U32Rotr => { let b = pop_u32!(self); let a = pop!(self).as_int(); self.stack.push(Felt::new(a.rotate_right(b))); } - Op::U32UncheckedRotrImm(imm) => { + Op::U32RotrImm(imm) => { let a = pop!(self).as_int(); self.stack.push(Felt::new(a.rotate_right(imm))); } - Op::U32CheckedPopcnt => { - let a = pop_u32!(self); - self.stack.push_u32(a.count_ones()); - } - Op::U32UncheckedPopcnt => { + Op::U32Popcnt => { let a = pop!(self).as_int(); self.stack.push_u32(a.count_ones()); } - Op::U32Eq => comparison32!(self, eq), - Op::U32EqImm(imm) => comparison32!(self, eq, imm), - Op::U32Neq => comparison32!(self, ne), - Op::U32NeqImm(imm) => comparison32!(self, ne, imm), - Op::U32CheckedGt => comparison32!(self, gt), - Op::U32UncheckedGt => comparison!(self, gt), - Op::U32CheckedGte => comparison32!(self, ge), - Op::U32UncheckedGte => comparison!(self, ge), - Op::U32CheckedLt => comparison32!(self, lt), - Op::U32UncheckedLt => comparison!(self, lt), - Op::U32CheckedLte => comparison32!(self, le), - Op::U32UncheckedLte => comparison!(self, le), - Op::U32CheckedMin => { - let b = pop_u32!(self); - let a = pop_u32!(self); - self.stack.push_u32(cmp::min(a, b)); - } - Op::U32UncheckedMin => { + Op::U32Gt => comparison!(self, gt), + Op::U32Gte => comparison!(self, ge), + Op::U32Lt => comparison!(self, lt), + Op::U32Lte => comparison!(self, le), + Op::U32Min => { let b = pop!(self).as_int(); let a = pop!(self).as_int(); self.stack.push(Felt::new(cmp::min(a, b))); } - Op::U32CheckedMax => { - let b = pop_u32!(self); - let a = pop_u32!(self); - self.stack.push_u32(cmp::max(a, b)); - } - Op::U32UncheckedMax => { + Op::U32Max => { let b = pop!(self).as_int(); let a = pop!(self).as_int(); self.stack.push(Felt::new(cmp::max(a, b))); } + op => unimplemented!("missing opcode implementation for {op:?}"), } match ix_with_op.effect { diff --git a/codegen/masm/src/masm/module.rs b/codegen/masm/src/masm/module.rs index 1f4b864f3..6fb786a39 100644 --- a/codegen/masm/src/masm/module.rs +++ b/codegen/masm/src/masm/module.rs @@ -7,11 +7,11 @@ use std::{ use intrusive_collections::{intrusive_adapter, RBTree, RBTreeAtomicLink}; use miden_assembly::ast::ModuleAst; -use miden_diagnostics::{CodeMap, SourceFile, SourceSpan, Spanned}; +use miden_diagnostics::{CodeMap, SourceFile, SourceSpan}; use miden_hir::{FunctionIdent, Ident, Symbol}; use rustc_hash::FxHashMap; -use super::{function::Functions, FrozenFunctionList, Function, Import, ModuleImportInfo}; +use super::{function::Functions, FrozenFunctionList, Function, ModuleImportInfo}; #[derive(Debug, thiserror::Error)] pub enum LoadModuleError { @@ -126,41 +126,12 @@ impl Module { span: SourceSpan, _codemap: &CodeMap, ) -> Self { - use miden_assembly::{ast::ModuleImports, ProcedureId}; - let module_name = name.into(); let mut module = Self::new(module_name); module.span = span; module.docs = ast.docs().cloned(); - // HACK: We're waiting on 0xPolygonMiden/miden-vm#1110 - let imported = { - let mut imports = BTreeMap::<_, miden_assembly::LibraryPath>::default(); - let mut invoked = BTreeMap::<_, (_, miden_assembly::LibraryPath)>::default(); - let import_paths = ast.import_paths(); - for path in import_paths.iter() { - let alias = Symbol::intern(path.last()); - let name = Symbol::intern(path.as_ref()); - module.imports.insert(Import { - span: module_name.span(), - alias, - name, - }); - imports.insert( - path.last().to_string(), - miden_assembly::LibraryPath::clone(path), - ); - } - for (id, name) in ast.get_imported_procedures_map().into_iter() { - let path = import_paths - .iter() - .find(|p| id == ProcedureId::from_name(name.as_ref(), p)) - .expect("could not find module for imported procedure"); - invoked.insert(id, (name.clone(), miden_assembly::LibraryPath::clone(path))); - } - ModuleImports::new(imports, invoked) - }; - + let imported = ast.import_info().clone(); let locals = ast .procs() .iter() diff --git a/codegen/masm/src/stackify/emit/binary.rs b/codegen/masm/src/stackify/emit/binary.rs index 3179d593b..aea71bd63 100644 --- a/codegen/masm/src/stackify/emit/binary.rs +++ b/codegen/masm/src/stackify/emit/binary.rs @@ -1,4 +1,4 @@ -use miden_hir::{assert_matches, Immediate, Overflow, Type}; +use miden_hir::{assert_matches, Felt, Immediate, Overflow, Type}; use crate::masm::Op; @@ -15,12 +15,22 @@ impl<'a> OpEmitter<'a> { self.eq_i128(); } Type::I64 | Type::U64 => { - self.emit(Op::Eqw); - } - Type::Felt => { - self.emit(Op::Eq); + // context: [b_hi, b_lo, a_hi, a_lo] + self.emit_all(&[ + // [a_hi, b_hi, b_lo, a_lo] + Op::Movup(2), + // [hi_equal, b_lo, a_lo] + Op::Eq, + // [b_lo, a_lo, hi_equal] + Op::Movdn(3), + // [lo_equal, hi_equal] + Op::Eq, + // [is_equal] + Op::And, + ]); } - Type::Ptr(_) + Type::Felt + | Type::Ptr(_) | Type::U32 | Type::I32 | Type::U16 @@ -28,7 +38,7 @@ impl<'a> OpEmitter<'a> { | Type::I8 | Type::U8 | Type::I1 => { - self.emit(Op::U32Eq); + self.emit(Op::Eq); } ty => unimplemented!("eq is not yet implemented for {ty}"), } @@ -46,16 +56,25 @@ impl<'a> OpEmitter<'a> { } Type::I64 | Type::U64 => { self.push_immediate(imm); - self.emit(Op::Eqw); + // context: [b_hi, b_lo, a_hi, a_lo] + self.emit_all(&[ + // [a_hi, b_hi, b_lo, a_lo] + Op::Movup(2), + // [hi_equal, b_lo, a_lo] + Op::Eq, + // [b_lo, a_lo, hi_equal] + Op::Movdn(3), + // [lo_equal, hi_equal] + Op::Eq, + // [is_equal] + Op::And, + ]); } - Type::Felt => { + Type::Felt | Type::Ptr(_) | Type::U32 | Type::U16 | Type::U8 | Type::I1 => { self.emit(Op::EqImm(imm.as_felt().unwrap())); } - Type::Ptr(_) | Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit(Op::U32EqImm(imm.as_u32().unwrap())); - } Type::I32 | Type::I16 | Type::I8 => { - self.emit(Op::U32EqImm(imm.as_i32().unwrap() as u32)); + self.emit(Op::EqImm(Felt::new(imm.as_i32().unwrap() as u32 as u64))); } ty => unimplemented!("eq is not yet implemented for {ty}"), } @@ -69,15 +88,24 @@ impl<'a> OpEmitter<'a> { assert_eq!(ty, rhs.ty(), "expected neq operands to be the same type"); match &ty { Type::I128 => { - self.eq_i128(); + self.neq_i128(); } Type::I64 | Type::U64 => { - self.emit_all(&[Op::Eqw, Op::Not]); - } - Type::Felt => { - self.emit(Op::Neq); + self.emit_all(&[ + // [a_hi, b_hi, b_lo, a_lo] + Op::Movup(2), + // [hi_not_equal, b_lo, a_lo] + Op::Neq, + // [b_lo, a_lo, hi_not_equal] + Op::Movdn(3), + // [lo_not_equal, hi_not_equal] + Op::Neq, + // [is_not_equal] + Op::Or, + ]); } - Type::Ptr(_) + Type::Felt + | Type::Ptr(_) | Type::U32 | Type::I32 | Type::U16 @@ -85,7 +113,7 @@ impl<'a> OpEmitter<'a> { | Type::I8 | Type::U8 | Type::I1 => { - self.emit(Op::U32Neq); + self.emit(Op::Neq); } ty => unimplemented!("neq is not yet implemented for {ty}"), } @@ -103,16 +131,24 @@ impl<'a> OpEmitter<'a> { } Type::I64 | Type::U64 => { self.push_immediate(imm); - self.emit_all(&[Op::Eqw, Op::Not]); + self.emit_all(&[ + // [a_hi, b_hi, b_lo, a_lo] + Op::Movup(2), + // [hi_not_equal, b_lo, a_lo] + Op::Neq, + // [b_lo, a_lo, hi_not_equal] + Op::Movdn(3), + // [lo_not_equal, hi_not_equal] + Op::Neq, + // [is_not_equal] + Op::Or, + ]); } - Type::Felt => { + Type::Felt | Type::Ptr(_) | Type::U32 | Type::U16 | Type::U8 | Type::I1 => { self.emit(Op::NeqImm(imm.as_felt().unwrap())); } - Type::Ptr(_) | Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit(Op::U32NeqImm(imm.as_u32().unwrap())); - } Type::I32 | Type::I16 | Type::I8 => { - self.emit(Op::U32NeqImm(imm.as_i32().unwrap() as u32)); + self.emit(Op::NeqImm(Felt::new(imm.as_i32().unwrap() as u32 as u64))); } ty => unimplemented!("neq is not yet implemented for {ty}"), } @@ -129,7 +165,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::Gt); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit(Op::U32CheckedGt); + self.emit(Op::U32Gt); } Type::I32 => self.emit(Op::Exec("intrinsics::i32::is_gt".parse().unwrap())), ty => unimplemented!("gt is not yet implemented for {ty}"), @@ -146,7 +182,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::GtImm(imm.as_felt().unwrap())); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32CheckedGt]); + self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32Gt]); } Type::I32 => { self.emit_all(&[ @@ -169,7 +205,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::Gte); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit(Op::U32CheckedGte); + self.emit(Op::U32Gte); } Type::I32 => self.emit(Op::Exec("intrinsics::i32::is_gte".parse().unwrap())), ty => unimplemented!("gte is not yet implemented for {ty}"), @@ -186,7 +222,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::GteImm(imm.as_felt().unwrap())); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32CheckedGte]); + self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32Gte]); } Type::I32 => { self.emit_all(&[ @@ -209,7 +245,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::Lt); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit(Op::U32CheckedLt); + self.emit(Op::U32Lt); } Type::I32 => self.emit(Op::Exec("intrinsics::i32::is_lt".parse().unwrap())), ty => unimplemented!("lt is not yet implemented for {ty}"), @@ -226,7 +262,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::LtImm(imm.as_felt().unwrap())); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32CheckedLt]); + self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32Lt]); } Type::I32 => { self.emit_all(&[ @@ -249,7 +285,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::Lte); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit(Op::U32CheckedLte); + self.emit(Op::U32Lte); } Type::I32 => self.emit(Op::Exec("intrinsics::i32::is_lte".parse().unwrap())), ty => unimplemented!("lte is not yet implemented for {ty}"), @@ -266,7 +302,7 @@ impl<'a> OpEmitter<'a> { self.emit(Op::LteImm(imm.as_felt().unwrap())); } Type::U32 | Type::U16 | Type::U8 | Type::I1 => { - self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32CheckedLte]); + self.emit_all(&[Op::PushU32(imm.as_u32().unwrap()), Op::U32Lte]); } Type::I32 => { self.emit_all(&[ @@ -313,6 +349,7 @@ impl<'a> OpEmitter<'a> { let ty = lhs.ty(); assert_eq!(ty, imm.ty(), "expected add operands to be the same type"); match &ty { + Type::Felt if imm == 1 => self.emit(Op::Incr), Type::Felt => { self.emit(Op::AddImm(imm.as_felt().unwrap())); } diff --git a/codegen/masm/src/stackify/emit/int32.rs b/codegen/masm/src/stackify/emit/int32.rs index 42fd76783..e5aaa910e 100644 --- a/codegen/masm/src/stackify/emit/int32.rs +++ b/codegen/masm/src/stackify/emit/int32.rs @@ -118,25 +118,6 @@ impl<'a> OpEmitter<'a> { self.emit(Op::Assertz); } - /// Check if the 32-bit value on the stack is a valid i32 value - pub fn is_i32(&mut self) { - self.emit_all(&[ - // Copy the input - Op::Dup(0), - // Check the value does not overflow i32::MAX or underflow i32::MIN - // This can be done by validating that when interpreted as a u32, - // the value is <= i32::MIN, which is 1 more than i32::MAX. - Op::PushU32(i32::MIN as u32), - Op::U32CheckedLte, - ]); - } - - /// Assert that the 32-bit value on the stack is a valid i32 value - pub fn assert_i32(&mut self) { - self.is_i32(); - self.emit(Op::Assert); - } - /// Emits code to assert that a 32-bit value on the operand stack is equal to the given constant value. /// /// The value on top of the stack IS NOT consumed. @@ -216,7 +197,7 @@ impl<'a> OpEmitter<'a> { pub fn int32_to_int(&mut self, n: u32) { assert_valid_integer_size!(n, 1, 32); // Push is_signed on the stack - self.is_i32(); + self.is_signed_int32(); // Pop the is_signed flag, and replace it with a selected mask // for the upper reserved bits of the N-bit range let reserved = 32 - n; @@ -242,7 +223,7 @@ impl<'a> OpEmitter<'a> { pub fn try_int32_to_int(&mut self, n: u32) { assert_valid_integer_size!(n, 1, 32); // Push is_signed on the stack - self.is_i32(); + self.is_signed_int32(); // Pop the is_signed flag, and replace it with a selected mask // for the upper reserved bits of the N-bit range let reserved = 32 - n; @@ -389,7 +370,7 @@ impl<'a> OpEmitter<'a> { pub fn add_u32(&mut self, overflow: Overflow) { self.emit(match overflow { Overflow::Unchecked => Op::Add, - Overflow::Checked => Op::U32CheckedAdd, + Overflow::Checked => return self.emit_all(&[Op::Add, Op::U32Assert]), Overflow::Wrapping => Op::U32WrappingAdd, Overflow::Overflowing => Op::U32OverflowingAdd, }); @@ -420,7 +401,9 @@ impl<'a> OpEmitter<'a> { self.emit(match overflow { Overflow::Unchecked if imm == 1 => Op::Incr, Overflow::Unchecked => Op::AddImm(Felt::new(imm as u64)), - Overflow::Checked => Op::U32CheckedAddImm(imm), + Overflow::Checked => { + return self.emit_all(&[Op::AddImm(Felt::new(imm as u64)), Op::U32Assert]); + } Overflow::Wrapping => Op::U32WrappingAddImm(imm), Overflow::Overflowing => Op::U32OverflowingAddImm(imm), }); @@ -457,7 +440,9 @@ impl<'a> OpEmitter<'a> { pub fn sub_u32(&mut self, overflow: Overflow) { self.emit(match overflow { Overflow::Unchecked => Op::Sub, - Overflow::Checked => Op::U32CheckedSub, + Overflow::Checked => { + return self.emit_all(&[Op::Sub, Op::U32Assert]); + } Overflow::Wrapping => Op::U32WrappingSub, Overflow::Overflowing => Op::U32OverflowingSub, }); @@ -490,7 +475,9 @@ impl<'a> OpEmitter<'a> { } self.emit(match overflow { Overflow::Unchecked => Op::SubImm(Felt::new(imm as u64)), - Overflow::Checked => Op::U32CheckedSubImm(imm), + Overflow::Checked => { + return self.emit_all(&[Op::SubImm(Felt::new(imm as u64)), Op::U32Assert]) + } Overflow::Wrapping => Op::U32WrappingSubImm(imm), Overflow::Overflowing => Op::U32OverflowingSubImm(imm), }); @@ -525,7 +512,7 @@ impl<'a> OpEmitter<'a> { pub fn mul_u32(&mut self, overflow: Overflow) { self.emit(match overflow { Overflow::Unchecked => Op::Mul, - Overflow::Checked => Op::U32CheckedMul, + Overflow::Checked => return self.emit_all(&[Op::Mul, Op::U32Assert]), Overflow::Wrapping => Op::U32WrappingMul, Overflow::Overflowing => Op::U32OverflowingMul, }); @@ -536,7 +523,9 @@ impl<'a> OpEmitter<'a> { /// See the [Overflow] type for how overflow semantics can change the operation. pub fn mul_i32(&mut self, overflow: Overflow) { match overflow { - Overflow::Unchecked | Overflow::Wrapping => self.mul_u32(overflow), + Overflow::Unchecked | Overflow::Wrapping => { + self.emit(Op::Exec("intrinsics::i32::wrapping_mul".parse().unwrap())) + } Overflow::Checked => { self.emit(Op::Exec("intrinsics::i32::checked_mul".parse().unwrap())) } @@ -564,7 +553,9 @@ impl<'a> OpEmitter<'a> { imm => { self.emit(match overflow { Overflow::Unchecked => Op::MulImm(Felt::new(imm as u64)), - Overflow::Checked => Op::U32CheckedMulImm(imm), + Overflow::Checked => { + return self.emit_all(&[Op::MulImm(Felt::new(imm as u64)), Op::U32Assert]) + } Overflow::Wrapping => Op::U32WrappingMulImm(imm), Overflow::Overflowing => Op::U32OverflowingMulImm(imm), }); @@ -588,9 +579,10 @@ impl<'a> OpEmitter<'a> { } 1 => (), imm => match overflow { - Overflow::Unchecked | Overflow::Wrapping => { - self.emit(Op::MulImm(Felt::new(imm as u32 as u64))); - } + Overflow::Unchecked | Overflow::Wrapping => self.emit_all(&[ + Op::PushU32(imm as u32), + Op::Exec("intrinsics::i32::wrapping_mul".parse().unwrap()), + ]), Overflow::Checked => self.emit_all(&[ Op::PushU32(imm as u32), Op::Exec("intrinsics::i32::checked_mul".parse().unwrap()), @@ -607,7 +599,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, so if the operands or result are not valid u32, execution traps. pub fn checked_div_u32(&mut self) { - self.emit(Op::U32CheckedDiv); + self.emit_all(&[Op::U32Div, Op::U32Assert]); } /// Pops two i32 values off the stack, `b` and `a`, and performs `a / b`. @@ -624,7 +616,7 @@ impl<'a> OpEmitter<'a> { /// This operation is checked, so if the operand or result are not valid u32, execution traps. pub fn checked_div_imm_u32(&mut self, imm: u32) { assert_ne!(imm, 0, "division by zero is not allowed"); - self.emit(Op::U32CheckedDivImm(imm)); + self.emit_all(&[Op::U32DivImm(imm), Op::U32Assert]); } /// Pops a i32 value off the stack, `a`, and performs `a / `. @@ -644,7 +636,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is unchecked, so the result is not guaranteed to be a valid u32 pub fn unchecked_div_u32(&mut self) { - self.emit(Op::U32UncheckedDiv); + self.emit(Op::U32Div); } /// Pops a u32 value off the stack, `a`, and performs `a / `. @@ -652,14 +644,14 @@ impl<'a> OpEmitter<'a> { /// This function will panic if the divisor is zero. pub fn unchecked_div_imm_u32(&mut self, imm: u32) { assert_ne!(imm, 0, "division by zero is not allowed"); - self.emit(Op::U32UncheckedDivImm(imm)); + self.emit(Op::U32DivImm(imm)); } /// Pops two u32 values off the stack, `b` and `a`, and performs `a % b`. /// /// This operation is checked, so if the operands or result are not valid u32, execution traps. pub fn checked_mod_u32(&mut self) { - self.emit(Op::U32CheckedMod); + self.emit_all(&[Op::U32Mod, Op::U32Assert]); } /// Pops a u32 value off the stack, `a`, and performs `a % `. @@ -669,14 +661,14 @@ impl<'a> OpEmitter<'a> { /// This operation is checked, so if the operand or result are not valid u32, execution traps. pub fn checked_mod_imm_u32(&mut self, imm: u32) { assert_ne!(imm, 0, "division by zero is not allowed"); - self.emit(Op::U32CheckedModImm(imm)); + self.emit_all(&[Op::U32ModImm(imm), Op::U32Assert]); } /// Pops two u32 values off the stack, `b` and `a`, and performs `a % b`. /// /// This operation is unchecked, so the result is not guaranteed to be a valid u32 pub fn unchecked_mod_u32(&mut self) { - self.emit(Op::U32UncheckedMod); + self.emit(Op::U32Mod); } /// Pops a u32 value off the stack, `a`, and performs `a % `. @@ -684,14 +676,14 @@ impl<'a> OpEmitter<'a> { /// This function will panic if the divisor is zero. pub fn unchecked_mod_imm_u32(&mut self, imm: u32) { assert_ne!(imm, 0, "division by zero is not allowed"); - self.emit(Op::U32UncheckedModImm(imm)); + self.emit(Op::U32ModImm(imm)); } /// Pops two u32 values off the stack, `b` and `a`, and pushes `a / b`, then `a % b` on the stack. /// /// This operation is checked, so if the operands or result are not valid u32, execution traps. pub fn checked_divmod_u32(&mut self) { - self.emit(Op::U32CheckedDivMod); + self.emit_all(&[Op::U32DivMod, Op::U32Assert]); } /// Pops a u32 value off the stack, `a`, and pushes `a / `, then `a % ` on the stack. @@ -699,14 +691,14 @@ impl<'a> OpEmitter<'a> { /// This operation is checked, so if the operands or result are not valid u32, execution traps. pub fn checked_divmod_imm_u32(&mut self, imm: u32) { assert_ne!(imm, 0, "division by zero is not allowed"); - self.emit(Op::U32CheckedDivModImm(imm)); + self.emit_all(&[Op::U32DivModImm(imm), Op::U32Assert]); } /// Pops two u32 values off the stack, `b` and `a`, and pushes `a / b`, then `a % b` on the stack. /// /// This operation is unchecked, so the result is not guaranteed to be a valid u32 pub fn unchecked_divmod_u32(&mut self) { - self.emit(Op::U32UncheckedDivMod); + self.emit(Op::U32DivMod); } /// Pops a u32 value off the stack, `a`, and pushes `a / `, then `a % ` on the stack. @@ -714,7 +706,7 @@ impl<'a> OpEmitter<'a> { /// This operation is unchecked, so the result is not guaranteed to be a valid u32 pub fn unchecked_divmod_imm_u32(&mut self, imm: u32) { assert_ne!(imm, 0, "division by zero is not allowed"); - self.emit(Op::U32UncheckedDivModImm(imm)); + self.emit(Op::U32DivModImm(imm)); } /// Pops two u32 values off the stack, `b` and `a`, and performs `a & b` @@ -763,7 +755,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operand or result are not valid u32, execution traps. pub fn bnot_u32(&mut self) { - self.emit(Op::U32CheckedSubImm(-1i32 as u32)); + self.emit(Op::U32WrappingSubImm(-1i32 as u32)); } /// Pops two u32 values off the stack, `b` and `a`, and performs `a << b` @@ -772,7 +764,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operands or result are not valid u32, execution traps. pub fn shl_u32(&mut self) { - self.emit(Op::U32CheckedShl); + self.emit(Op::U32Shl); } /// Pops a u32 value off the stack, `a`, and performs `a << ` @@ -780,7 +772,7 @@ impl<'a> OpEmitter<'a> { /// This operation is checked, if the operand or result are not valid u32, execution traps. pub fn shl_imm_u32(&mut self, imm: u32) { assert!(imm < 32, "invalid shift value: must be < 32, got {imm}"); - self.emit(Op::U32CheckedShlImm(imm)); + self.emit(Op::U32ShlImm(imm)); } /// Pops two u32 values off the stack, `b` and `a`, and performs `a >> b` @@ -789,7 +781,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operands or result are not valid u32, execution traps. pub fn shr_u32(&mut self) { - self.emit(Op::U32CheckedShr); + self.emit(Op::U32Shr); } /// Pops two i32 values off the stack, `b` and `a`, and performs `a >> b` @@ -806,7 +798,7 @@ impl<'a> OpEmitter<'a> { /// This operation is checked, if the operand or result are not valid u32, execution traps. pub fn shr_imm_u32(&mut self, imm: u32) { assert!(imm < 32, "invalid shift value: must be < 32, got {imm}"); - self.emit(Op::U32CheckedShrImm(imm)); + self.emit(Op::U32ShrImm(imm)); } /// Pops a i32 value off the stack, `a`, and performs `a >> ` @@ -826,7 +818,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operands or result are not valid u32, execution traps. pub fn rotl_u32(&mut self) { - self.emit(Op::U32CheckedRotl); + self.emit(Op::U32Rotl); } /// Pops a u32 value off the stack, `a`, and rotates the bits of `a` left by `imm` bits @@ -834,7 +826,7 @@ impl<'a> OpEmitter<'a> { /// This operation is checked, if the operand or result are not valid u32, execution traps. pub fn rotl_imm_u32(&mut self, imm: u32) { assert!(imm < 32, "invalid rotation value: must be < 32, got {imm}"); - self.emit(Op::U32CheckedRotlImm(imm)); + self.emit(Op::U32RotlImm(imm)); } /// Pops two u32 values off the stack, `b` and `a`, and rotates the bits of `a` right by `b` bits @@ -843,7 +835,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operands or result are not valid u32, execution traps. pub fn rotr_u32(&mut self) { - self.emit(Op::U32CheckedRotr); + self.emit(Op::U32Rotr); } /// Pops a u32 value off the stack, `a`, and rotates the bits of `a` right by `imm` bits @@ -851,14 +843,14 @@ impl<'a> OpEmitter<'a> { /// This operation is checked, if the operand or result are not valid u32, execution traps. pub fn rotr_imm_u32(&mut self, imm: u32) { assert!(imm < 32, "invalid rotation value: must be < 32, got {imm}"); - self.emit(Op::U32CheckedRotrImm(imm)); + self.emit(Op::U32RotrImm(imm)); } /// Pops two u32 values off the stack, `b` and `a`, and puts the result of `min(a, b)` on the stack /// /// This operation is checked, if the operands or result are not valid u32, execution traps. pub fn min_u32(&mut self) { - self.emit(Op::U32CheckedMin); + self.emit(Op::U32Min); } /// Pops two i32 values off the stack, `b` and `a`, and puts the result of `min(a, b)` on the stack @@ -872,7 +864,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operand or result are not valid u32, execution traps. pub fn min_imm_u32(&mut self, imm: u32) { - self.emit_all(&[Op::PushU32(imm), Op::U32CheckedMin]); + self.emit_all(&[Op::PushU32(imm), Op::U32Min]); } /// Pops a i32 value off the stack, `a`, and puts the result of `min(a, imm)` on the stack @@ -889,7 +881,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operands or result are not valid u32, execution traps. pub fn max_u32(&mut self) { - self.emit(Op::U32CheckedMax); + self.emit(Op::U32Max); } /// Pops two i32 values off the stack, `b` and `a`, and puts the result of `max(a, b)` on the stack @@ -903,7 +895,7 @@ impl<'a> OpEmitter<'a> { /// /// This operation is checked, if the operand or result are not valid u32, execution traps. pub fn max_imm_u32(&mut self, imm: u32) { - self.emit_all(&[Op::PushU32(imm), Op::U32CheckedMax]); + self.emit_all(&[Op::PushU32(imm), Op::U32Max]); } /// Pops a i32 value off the stack, `a`, and puts the result of `max(a, imm)` on the stack diff --git a/codegen/masm/src/stackify/emit/int64.rs b/codegen/masm/src/stackify/emit/int64.rs index 3d5a8f335..65cf75eb6 100644 --- a/codegen/masm/src/stackify/emit/int64.rs +++ b/codegen/masm/src/stackify/emit/int64.rs @@ -38,7 +38,7 @@ impl<'a> OpEmitter<'a> { // Check that the remaining bits fit in range Op::Dup(0), Op::Push(Felt::new(2u64.pow(n) - 1)), - Op::U32UncheckedLte, + Op::U32Lte, ]); } diff --git a/codegen/masm/src/stackify/emit/mem.rs b/codegen/masm/src/stackify/emit/mem.rs index 262e66deb..d42729772 100644 --- a/codegen/masm/src/stackify/emit/mem.rs +++ b/codegen/masm/src/stackify/emit/mem.rs @@ -91,25 +91,25 @@ impl<'a> OpEmitter<'a> { // Obtain the absolute offset // // [abs_offset, addr] - Op::U32CheckedModImm(16), + Op::U32ModImm(16), // Obtain the byte offset // // [abs_offset, abs_offset, addr] Op::Dup(0), // [offset, abs_offset, addr] - Op::U32CheckedModImm(4), + Op::U32ModImm(4), // Obtain the element index // // [abs_offset, offset, addr] Op::Swap(1), // [index, byte_offset, addr] - Op::U32CheckedDivImm(4), + Op::U32DivImm(4), // Translate the address to Miden's address space // // [addr, index, offset] Op::Movup(2), // [waddr, index, offset] - Op::U32CheckedDivImm(16), + Op::U32DivImm(16), ]); } @@ -195,10 +195,10 @@ impl<'a> OpEmitter<'a> { Op::Drop, Op::Drop, // Shift the high bits left by the offset - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Move the low bits to the top and shift them right Op::Swap(1), - Op::U32CheckedShrImm(rshift), + Op::U32ShrImm(rshift), // OR the high and low bits together Op::U32Or, ]); @@ -229,10 +229,10 @@ impl<'a> OpEmitter<'a> { // Drop the remaining unused element Op::Drop, // Shift the high bits left by the offset - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Move the low bits to the top and shift them right Op::Swap(1), - Op::U32CheckedShrImm(rshift), + Op::U32ShrImm(rshift), // OR the high and low bits together Op::U32Or, ]); @@ -257,10 +257,10 @@ impl<'a> OpEmitter<'a> { Op::Drop, Op::Drop, // Shift the high bits left by the offset - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Move the low bits to the top and shift them right Op::Swap(1), - Op::U32CheckedShrImm(rshift), + Op::U32ShrImm(rshift), // OR the high and low bits together Op::U32Or, ]); @@ -286,7 +286,7 @@ impl<'a> OpEmitter<'a> { Op::Drop, Op::Drop, // Shift the low bits right by the offset - Op::U32CheckedShrImm(rshift), + Op::U32ShrImm(rshift), // Load the quad-word containing the high bits Op::Padw, Op::MemLoadwImm(ptr.waddr), @@ -295,7 +295,7 @@ impl<'a> OpEmitter<'a> { Op::Drop, Op::Drop, // Shift the high bits left by the offset - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // OR the high and low bits together Op::U32Or, ]); @@ -621,7 +621,7 @@ impl<'a> OpEmitter<'a> { // This gives us the first half of the first word. // // [x_hi_hi, chunk_mid, chunk__lo] - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Move the value below the other chunks temporarily // // [chunk_mid, chunk_lo, x_hi_hi] @@ -641,7 +641,7 @@ impl<'a> OpEmitter<'a> { // isolating them. // // [x_hi_lo, chunk_mid, chunk_lo, x_hi_hi] - Op::U32CheckedShrImm(32 - ptr.offset as u32), + Op::U32ShrImm(32 - ptr.offset as u32), // Move the high bits back to the top // // [x_hi_hi, x_hi_lo, chunk_mid, chunk_lo] @@ -659,11 +659,11 @@ impl<'a> OpEmitter<'a> { // This gives us the first half of the second word. // // [x_lo_hi, chunk_lo, x_hi] - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Next, swap the low bit chunk to the top temporarily Op::Swap(1), // Shift the value right, as done previously for the middle chunk - Op::U32CheckedShrImm(32 - ptr.offset as u32), + Op::U32ShrImm(32 - ptr.offset as u32), // OR the two halves together, giving us our second word, `x_lo` // // [x_lo, x_hi] @@ -702,7 +702,7 @@ impl<'a> OpEmitter<'a> { // This gives us the first half of `x_hi2`. // // [x_hi2_hi, chunk_mid_hi, chunk_mid_mid, chunk_mid_lo, chunk__lo] - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Move the value below the other chunks temporarily // // [chunk_mid_hi, chunk_mid_mid, chunk_mid_lo, chunk__lo, x_hi2_hi] @@ -720,7 +720,7 @@ impl<'a> OpEmitter<'a> { // re-aligning the low bits of `x_hi2`, and isolating them. // // [x_hi2_lo, chunk_mid_hi, chunk_mid_mid, chunk_mid_lo, chunk_lo, x_hi2_hi] - Op::U32CheckedShrImm(32 - ptr.offset as u32), + Op::U32ShrImm(32 - ptr.offset as u32), // Move the high bits of `x_hi2` back to the top // // [x_hi2_hi, x_hi2_lo, chunk_mid_hi, chunk_mid_mid, chunk_mid_lo, chunk_lo] @@ -739,7 +739,7 @@ impl<'a> OpEmitter<'a> { // This gives us the first half of `x_hi1` // // [x_hi1_hi, chunk_mid_mid, chunk_mid_lo, chunk_lo, x_hi2] - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Next, move the chunk containing the low bits of `x_hi1` to the top temporarily // // [chunk_mid_mid, chunk_mid_lo, chunk_lo, x_hi2, x_hi1_hi] @@ -751,7 +751,7 @@ impl<'a> OpEmitter<'a> { // Shift the value right, as done previously for the low bits of `x_hi2` // // [x_hi1_lo, chunk_mid_mid, chunk_mid_lo, chunk_lo, x_hi2, x_hi1_hi] - Op::U32CheckedShrImm(32 - ptr.offset as u32), + Op::U32ShrImm(32 - ptr.offset as u32), // Move the high bits of `x_hi1` to the top Op::Movup(5), // OR the two halves together, giving us our second word, `x_hi1` @@ -766,7 +766,7 @@ impl<'a> OpEmitter<'a> { // the remaining copy of `chunk_mid_mid`, as done previously. // // [x_lo2_hi, chunk_mid_lo, chunk_lo, x_hi2, x_hi1] - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Next, move the chunk containing the low bits of `x_lo2` to the top temporarily // // [chunk_mid_lo, chunk_lo, x_hi2, x_hi1, x_lo2_hi] @@ -778,7 +778,7 @@ impl<'a> OpEmitter<'a> { // Shift the value right to get the low bits of `x_lo2` // // [x_lo2_lo, chunk_mid_lo, chunk_lo, x_hi2, x_hi1, x_lo2_hi] - Op::U32CheckedShrImm(32 - ptr.offset as u32), + Op::U32ShrImm(32 - ptr.offset as u32), // Move the high bits of `x_lo2` to the top // // [x_lo2_hi, x_lo2_lo, chunk_mid_lo, chunk_lo, x_hi2, x_hi1] @@ -794,13 +794,13 @@ impl<'a> OpEmitter<'a> { // Re-align the high bits of `x_lo1` // // [x_lo1_hi, chunk_lo, x_hi2, x_hi1, x_lo2] - Op::U32CheckedShlImm(ptr.offset as u32), + Op::U32ShlImm(ptr.offset as u32), // Move the chunk containing the low bits to the top // // [chunk_lo, x_hi2, x_hi1, x_lo2, x_lo1_hi] Op::Movdn(5), // Shift the value right to get the low bits of `x_lo1` - Op::U32CheckedShrImm(32 - ptr.offset as u32), + Op::U32ShrImm(32 - ptr.offset as u32), // Move the high bits of `x_lo1` to the top // // [x_lo1_hi, x_lo1_lo, x_hi2, x_hi1, x_lo2] diff --git a/codegen/masm/src/stackify/emit/smallint.rs b/codegen/masm/src/stackify/emit/smallint.rs index 5a2d2cc1e..87e75a732 100644 --- a/codegen/masm/src/stackify/emit/smallint.rs +++ b/codegen/masm/src/stackify/emit/smallint.rs @@ -313,13 +313,13 @@ impl<'a> OpEmitter<'a> { match overflow { Overflow::Unchecked => (), Overflow::Checked => self.int32_to_uint(n), - Overflow::Wrapping => self.emit(Op::U32CheckedModImm(2u32.pow(n))), + Overflow::Wrapping => self.emit(Op::U32ModImm(2u32.pow(n))), Overflow::Overflowing => { self.try_int32_to_uint(n); self.emit_all(&[ // move result to top, and wrap it at 2^n Op::Swap(1), - Op::U32CheckedModImm(2u32.pow(n)), + Op::U32ModImm(2u32.pow(n)), // move is_valid flag to top, and invert it Op::Swap(1), Op::Not, diff --git a/codegen/masm/src/stackify/emit/unary.rs b/codegen/masm/src/stackify/emit/unary.rs index 0d0d8540d..c3ec0c2a6 100644 --- a/codegen/masm/src/stackify/emit/unary.rs +++ b/codegen/masm/src/stackify/emit/unary.rs @@ -367,21 +367,21 @@ impl<'a> OpEmitter<'a> { Type::I128 => { self.emit_all(&[ // [x3, x2, x1, x0] - Op::U32CheckedPopcnt, + Op::U32Popcnt, // [popcnt3, x2, x1, x0] Op::Swap(1), // [x2, popcnt3, x1, x0] - Op::U32CheckedPopcnt, + Op::U32Popcnt, // [popcnt2, popcnt3, x1, x0] Op::Add, // [popcnt_hi, x1, x0] Op::Movdn(2), // [x1, x0, popcnt] - Op::U32CheckedPopcnt, + Op::U32Popcnt, // [popcnt1, x0, popcnt] Op::Swap(1), // [x0, popcnt1, popcnt] - Op::U32CheckedPopcnt, + Op::U32Popcnt, // [popcnt0, popcnt1, popcnt] // // This last instruction adds all three values together mod 2^32 @@ -391,16 +391,16 @@ impl<'a> OpEmitter<'a> { Type::I64 | Type::U64 => { self.emit_all(&[ // Get popcnt of high bits - Op::U32CheckedPopcnt, + Op::U32Popcnt, // Swap to low bits and repeat Op::Swap(1), - Op::U32CheckedPopcnt, + Op::U32Popcnt, // Add both counts to get the total count Op::Add, ]); } Type::I32 | Type::U32 | Type::I16 | Type::U16 | Type::I8 | Type::U8 | Type::I1 => { - self.emit(Op::U32CheckedPopcnt); + self.emit(Op::U32Popcnt); } ty if !ty.is_integer() => { panic!("invalid popcnt on {ty}: only integral types can be negated") diff --git a/hir/Cargo.toml b/hir/Cargo.toml index bef01d6f2..3146b8bfc 100644 --- a/hir/Cargo.toml +++ b/hir/Cargo.toml @@ -34,7 +34,7 @@ rustc-hash.workspace = true smallvec.workspace = true thiserror.workspace = true typed-arena = "2.0" -winter-math = { version = "0.6", default-features = false } +winter-math = { version = "0.7", default-features = false } [dev-dependencies] pretty_assertions = "1.0" diff --git a/hir/src/asm/builder.rs b/hir/src/asm/builder.rs index bbf21dcd7..2beb21e66 100644 --- a/hir/src/asm/builder.rs +++ b/hir/src/asm/builder.rs @@ -262,23 +262,35 @@ impl<'a> MasmOpBuilder<'a> { } /// Pops the top element on the stack, and traps if that element is != 1. - pub fn assert(mut self) { - self.build(self.ip, MasmOp::Assert); + pub fn assert(mut self, error_code: Option) { + let op = error_code + .map(MasmOp::AssertWithError) + .unwrap_or(MasmOp::Assert); + self.build(self.ip, op); } /// Pops the top element on the stack, and traps if that element is != 0. - pub fn assertz(mut self) { - self.build(self.ip, MasmOp::Assertz); + pub fn assertz(mut self, error_code: Option) { + let op = error_code + .map(MasmOp::AssertzWithError) + .unwrap_or(MasmOp::Assertz); + self.build(self.ip, op); } /// Pops the top two elements on the stack, and traps if they are not equal. - pub fn assert_eq(mut self) { - self.build(self.ip, MasmOp::AssertEq); + pub fn assert_eq(mut self, error_code: Option) { + let op = error_code + .map(MasmOp::AssertEqWithError) + .unwrap_or(MasmOp::AssertEq); + self.build(self.ip, op); } /// Pops the top two words on the stack, and traps if they are not equal. - pub fn assert_eqw(mut self) { - self.build(self.ip, MasmOp::AssertEq); + pub fn assert_eqw(mut self, error_code: Option) { + let op = error_code + .map(MasmOp::AssertEqwWithError) + .unwrap_or(MasmOp::AssertEqw); + self.build(self.ip, op); } /// Pops an element containing a memory address from the top of the stack, @@ -464,11 +476,23 @@ impl<'a> MasmOpBuilder<'a> { self.build(self.ip, MasmOp::Exec(id)); } + /// Execute a procedure indirectly. + /// + /// Expects the hash of a function's MAST root on the stack, see `procref` + pub fn dynexec(mut self) { + self.build(self.ip, MasmOp::DynExec) + } + /// Executes the named procedure as a syscall. pub fn syscall(mut self, id: FunctionIdent) { self.build(self.ip, MasmOp::Syscall(id)); } + /// Push the hash of the named function on the stack for use with dyn(exec|call) + pub fn procref(mut self, id: FunctionIdent) { + self.build(self.ip, MasmOp::ProcRef(id)) + } + /// Pops two field elements from the stack, adds them, and places the result on the stack. pub fn add(mut self) { self.build(self.ip, MasmOp::Add); @@ -670,6 +694,11 @@ impl<'a> MasmOpBuilder<'a> { self.build(self.ip, MasmOp::Clk); } + /// Pushes the hash of the caller on the stack + pub fn caller(mut self) { + self.build(self.ip, MasmOp::Caller); + } + /// Pushes 1 on the stack if the element on top of the stack is less than 2^32, else 0. pub fn test_u32(mut self) { self.build(self.ip, MasmOp::U32Test); @@ -681,18 +710,27 @@ impl<'a> MasmOpBuilder<'a> { } /// Traps if the element on top of the stack is greater than or equal to 2^32 - pub fn assert_u32(mut self) { - self.build(self.ip, MasmOp::U32Assert); + pub fn assert_u32(mut self, error_code: Option) { + let op = error_code + .map(MasmOp::U32AssertWithError) + .unwrap_or(MasmOp::U32Assert); + self.build(self.ip, op); } /// Traps if either of the first two elements on top of the stack are greater than or equal to 2^32 - pub fn assert2_u32(mut self) { - self.build(self.ip, MasmOp::U32Assert2); + pub fn assert2_u32(mut self, error_code: Option) { + let op = error_code + .map(MasmOp::U32Assert2WithError) + .unwrap_or(MasmOp::U32Assert2); + self.build(self.ip, op); } /// Traps if any element of the first word on the stack are greater than or equal to 2^32 - pub fn assertw_u32(mut self) { - self.build(self.ip, MasmOp::U32Assertw); + pub fn assertw_u32(mut self, error_code: Option) { + let op = error_code + .map(MasmOp::U32AssertwWithError) + .unwrap_or(MasmOp::U32Assertw); + self.build(self.ip, op); } /// Casts the element on top of the stack, `a`, to a valid u32 value, by computing `a mod 2^32` @@ -715,7 +753,12 @@ impl<'a> MasmOpBuilder<'a> { pub fn add_u32(mut self, overflow: Overflow) { let op = match overflow { Overflow::Unchecked => MasmOp::Add, - Overflow::Checked => MasmOp::U32CheckedAdd, + Overflow::Checked => { + return self.build_many( + self.ip, + [MasmOp::U32Assert2, MasmOp::Add, MasmOp::U32Assert], + ); + } Overflow::Overflowing => MasmOp::U32OverflowingAdd, Overflow::Wrapping => MasmOp::U32WrappingAdd, }; @@ -725,8 +768,18 @@ impl<'a> MasmOpBuilder<'a> { /// Same as above, but `a` is provided by the given immediate. pub fn add_imm_u32(mut self, imm: u32, overflow: Overflow) { let op = match overflow { + Overflow::Unchecked if imm == 1 => MasmOp::Incr, Overflow::Unchecked => MasmOp::AddImm(Felt::new(imm as u64)), - Overflow::Checked => MasmOp::U32CheckedAddImm(imm), + Overflow::Checked => { + return self.build_many( + self.ip, + [ + MasmOp::U32Assert, + MasmOp::AddImm(Felt::new(imm as u64)), + MasmOp::U32Assert, + ], + ); + } Overflow::Overflowing => MasmOp::U32OverflowingAddImm(imm), Overflow::Wrapping => MasmOp::U32WrappingAddImm(imm), }; @@ -753,7 +806,12 @@ impl<'a> MasmOpBuilder<'a> { pub fn sub_u32(mut self, overflow: Overflow) { let op = match overflow { Overflow::Unchecked => MasmOp::Sub, - Overflow::Checked => MasmOp::U32CheckedSub, + Overflow::Checked => { + return self.build_many( + self.ip, + [MasmOp::U32Assert2, MasmOp::Sub, MasmOp::U32Assert], + ); + } Overflow::Overflowing => MasmOp::U32OverflowingSub, Overflow::Wrapping => MasmOp::U32WrappingSub, }; @@ -764,7 +822,16 @@ impl<'a> MasmOpBuilder<'a> { pub fn sub_imm_u32(mut self, imm: u32, overflow: Overflow) { let op = match overflow { Overflow::Unchecked => MasmOp::SubImm(Felt::new(imm as u64)), - Overflow::Checked => MasmOp::U32CheckedSubImm(imm), + Overflow::Checked => { + return self.build_many( + self.ip, + [ + MasmOp::U32Assert, + MasmOp::SubImm(Felt::new(imm as u64)), + MasmOp::U32Assert, + ], + ); + } Overflow::Overflowing => MasmOp::U32OverflowingSubImm(imm), Overflow::Wrapping => MasmOp::U32WrappingSubImm(imm), }; @@ -778,7 +845,12 @@ impl<'a> MasmOpBuilder<'a> { pub fn mul_u32(mut self, overflow: Overflow) { let op = match overflow { Overflow::Unchecked => MasmOp::Mul, - Overflow::Checked => MasmOp::U32CheckedMul, + Overflow::Checked => { + return self.build_many( + self.ip, + [MasmOp::U32Assert2, MasmOp::Mul, MasmOp::U32Assert], + ); + } Overflow::Overflowing => MasmOp::U32OverflowingMul, Overflow::Wrapping => MasmOp::U32WrappingMul, }; @@ -789,7 +861,16 @@ impl<'a> MasmOpBuilder<'a> { pub fn mul_imm_u32(mut self, imm: u32, overflow: Overflow) { let op = match overflow { Overflow::Unchecked => MasmOp::MulImm(Felt::new(imm as u64)), - Overflow::Checked => MasmOp::U32CheckedMulImm(imm), + Overflow::Checked => { + return self.build_many( + self.ip, + [ + MasmOp::U32Assert, + MasmOp::MulImm(Felt::new(imm as u64)), + MasmOp::U32Assert, + ], + ); + } Overflow::Overflowing => MasmOp::U32OverflowingMulImm(imm), Overflow::Wrapping => MasmOp::U32WrappingMulImm(imm), }; @@ -812,89 +893,45 @@ impl<'a> MasmOpBuilder<'a> { /// Performs unsigned division of the top two elements on the stack, `b` and `a` respectively, which /// are expected to be valid u32 values. /// - /// This operation is checked, meaning that if either operand is >= 2^32, then it will trap. + /// This operation is unchecked, so if either operand is >= 2^32, the result is undefined. /// /// Traps if `b` is 0. pub fn div_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedDiv); + self.build(self.ip, MasmOp::U32Div); } /// Same as above, but `b` is provided by the given immediate pub fn div_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32CheckedDivImm(imm)); - } - - /// Performs unsigned division of the top two elements on the stack, `b` and `a` respectively, which - /// are expected to be valid u32 values. - /// - /// This operation is unchecked, so if either operand is >= 2^32, the result is undefined. - /// - /// Traps if `b` is 0. - pub fn div_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedDiv); - } - - /// Same as above, but `b` is provided by the given immediate - pub fn div_imm_unchecked_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32UncheckedDivImm(imm)); + self.build(self.ip, MasmOp::U32DivImm(imm)); } /// Pops two elements off the stack, `b` and `a` respectively, and computes `a mod b`. /// - /// This operation is checked, meaning that if either operand is >= 2^32, then it will trap. + /// This operation is unchecked, so if either operand is >= 2^32, the result is undefined. /// /// Traps if `b` is 0. pub fn mod_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedMod); + self.build(self.ip, MasmOp::U32Mod); } /// Same as above, but `b` is provided by the given immediate pub fn mod_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32CheckedModImm(imm)); - } - - /// Pops two elements off the stack, `b` and `a` respectively, and computes `a mod b`. - /// - /// This operation is unchecked, so if either operand is >= 2^32, the result is undefined. - /// - /// Traps if `b` is 0. - pub fn mod_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedMod); - } - - /// Same as above, but `b` is provided by the given immediate - pub fn mod_imm_unchecked_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32UncheckedModImm(imm)); + self.build(self.ip, MasmOp::U32ModImm(imm)); } /// Pops two elements off the stack, `b` and `a` respectively, and computes `a / b`, and `a mod b`, /// pushing the results of each on the stack in that order. /// - /// This operation is checked, meaning that if either operand is >= 2^32, then it will trap. + /// This operation is unchecked, so if either operand is >= 2^32, the results are undefined. /// /// Traps if `b` is 0. pub fn divmod_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedDivMod); + self.build(self.ip, MasmOp::U32DivMod); } /// Same as above, but `b` is provided by the given immediate pub fn divmod_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32CheckedDivModImm(imm)); - } - - /// Pops two elements off the stack, `b` and `a` respectively, and computes `a / b`, and `a mod b`, - /// pushing the results of each on the stack in that order. - /// - /// This operation is unchecked, so if either operand is >= 2^32, the results are undefined. - /// - /// Traps if `b` is 0. - pub fn divmod_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedDivMod); - } - - /// Same as above, but `b` is provided by the given immediate - pub fn divmod_imm_unchecked_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32UncheckedDivModImm(imm)); + self.build(self.ip, MasmOp::U32DivModImm(imm)); } /// Pops two elements off the stack, and computes the bitwise AND of those values, placing the result on the stack. @@ -928,201 +965,103 @@ impl<'a> MasmOpBuilder<'a> { /// Pops two elements off the stack, `b` and `a` respectively, and shifts `a` left by `b` bits. More precisely, /// the result is computed as `(a * 2^b) mod 2^32`. /// - /// Traps if `a` is not a valid u32, or `b` > 31. + /// The result is undefined if `a` is not a valid u32, or `b` is > 31. pub fn shl_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedShl); + self.build(self.ip, MasmOp::U32Shl); } /// Same as `shl_u32`, but `b` is provided by immediate. pub fn shl_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32CheckedShlImm(imm)); - } - - /// Pops two elements off the stack, `b` and `a` respectively, and shifts `a` left by `b` bits. More precisely, - /// the result is computed as `(a * 2^b) mod 2^32`. - /// - /// The result is undefined if `a` is not a valid u32, or `b` is > 31. - pub fn shl_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedShl); - } - - /// Same as `shl_unchecked_u32`, but `b` is provided by immediate. - pub fn shl_unchecked_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32UncheckedShlImm(imm)); + self.build(self.ip, MasmOp::U32ShlImm(imm)); } /// Pops two elements off the stack, `b` and `a` respectively, and shifts `a` right by `b` bits. More precisely, /// the result is computed as `a / 2^b`. /// - /// Traps if `a` is not a valid u32, or `b` > 31. + /// The result is undefined if `a` is not a valid u32, or `b` is > 31. pub fn shr_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedShr); + self.build(self.ip, MasmOp::U32Shr); } /// Same as `shr_u32`, but `b` is provided by immediate. pub fn shr_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32CheckedShrImm(imm)); - } - - /// Pops two elements off the stack, `b` and `a` respectively, and shifts `a` right by `b` bits. More precisely, - /// the result is computed as `a / 2^b`. - /// - /// The result is undefined if `a` is not a valid u32, or `b` is > 31. - pub fn shr_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedShr); - } - - /// Same as `shr_unchecked_u32`, but `b` is provided by immediate. - pub fn shr_unchecked_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32UncheckedShrImm(imm)); + self.build(self.ip, MasmOp::U32ShrImm(imm)); } /// Pops two elements off the stack, `b` and `a` respectively, and rotates the binary representation of `a` /// left by `b` bits. /// - /// Traps if `a` is not a valid u32, or `b` > 31 + /// The result is undefined if `a` is not a valid u32, or `b` is > 31. pub fn rotl_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedRotl); + self.build(self.ip, MasmOp::U32Rotl); } /// Same as `rotl_u32`, but `b` is provided by immediate. pub fn rotl_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32CheckedRotlImm(imm)); - } - - /// Pops two elements off the stack, `b` and `a` respectively, and rotates the binary representation of `a` - /// left by `b` bits. - /// - /// The result is undefined if `a` is not a valid u32, or `b` is > 31. - pub fn rotl_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedRotl); - } - - /// Same as `rotl_unchecked_u32`, but `b` is provided by immediate. - pub fn rotl_unchecked_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32UncheckedRotlImm(imm)); + self.build(self.ip, MasmOp::U32RotlImm(imm)); } /// Pops two elements off the stack, `b` and `a` respectively, and rotates the binary representation of `a` /// right by `b` bits. /// - /// Traps if `a` is not a valid u32, or `b` > 31 + /// The result is undefined if `a` is not a valid u32, or `b` is > 31. pub fn rotr_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedRotr); + self.build(self.ip, MasmOp::U32Rotr); } /// Same as `rotr_u32`, but `b` is provided by immediate. pub fn rotr_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32CheckedRotrImm(imm)); - } - - /// Pops two elements off the stack, `b` and `a` respectively, and rotates the binary representation of `a` - /// right by `b` bits. - /// - /// The result is undefined if `a` is not a valid u32, or `b` is > 31. - pub fn rotr_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedRotr); - } - - /// Same as `rotr_unchecked_u32`, but `b` is provided by immediate. - pub fn rotr_unchecked_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32UncheckedRotrImm(imm)); + self.build(self.ip, MasmOp::U32RotrImm(imm)); } /// Pops an element off the stack, and computes the number of set bits in its binary representation, i.e. /// its hamming weight, and places the result on the stack. /// - /// Traps if the input value is not a valid u32. + /// The result is undefined if the input value is not a valid u32. pub fn popcnt_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedPopcnt); + self.build(self.ip, MasmOp::U32Popcnt); } - /// Pops an element off the stack, and computes the number of set bits in its binary representation, i.e. - /// its hamming weight, and places the result on the stack. + /// Pushes a boolean on the stack by computing `a < b` for `[b, a]` /// - /// The result is undefined if the input value is not a valid u32. - pub fn popcnt_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedPopcnt); - } - - /// This is the same as `eq`, but also asserts that both operands are valid u32 values. - pub fn eq_u32(mut self) { - self.build(self.ip, MasmOp::U32Eq); - } - - /// This is the same as `eq_imm`, but also asserts that both operands are valid u32 values. - pub fn eq_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32EqImm(imm)); - } - - /// This is the same as `neq`, but also asserts that both operands are valid u32 values. - pub fn neq_u32(mut self) { - self.build(self.ip, MasmOp::U32Neq); - } - - /// This is the same as `neq_imm`, but also asserts that both operands are valid u32 values. - pub fn neq_imm_u32(mut self, imm: u32) { - self.build(self.ip, MasmOp::U32NeqImm(imm)); - } - - /// This is the same as `lt`, but also asserts that both operands are valid u32 values. + /// The result is undefined if either operand is not a valid u32 value. pub fn lt_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedLt); - } - - /// This is the same as `lt`, but the result is undefined if either operand is not a valid u32 value. - pub fn lt_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedLt); + self.build(self.ip, MasmOp::U32Lt); } - /// This is the same as `lte`, but also asserts that both operands are valid u32 values. + /// Pushes a boolean on the stack by computing `a <= b` for `[b, a]` + /// + /// The result is undefined if either operand is not a valid u32 value. pub fn lte_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedLte); - } - - /// This is the same as `lte`, but the result is undefined if either operand is not a valid u32 value. - pub fn lte_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedLte); + self.build(self.ip, MasmOp::U32Lte); } - /// This is the same as `gt`, but also asserts that both operands are valid u32 values. + /// Pushes a boolean on the stack by computing `a > b` for `[b, a]` + /// + /// The result is undefined if either operand is not a valid u32 value. pub fn gt_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedGt); - } - - /// This is the same as `gt`, but the result is undefined if either operand is not a valid u32 value. - pub fn gt_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedGt); + self.build(self.ip, MasmOp::U32Gt); } - /// This is the same as `gte`, but also asserts that both operands are valid u32 values. + /// Pushes a boolean on the stack by computing `a >= b` for `[b, a]` + /// + /// The result is undefined if either operand is not a valid u32 value. pub fn gte_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedGte); + self.build(self.ip, MasmOp::U32Gte); } - /// This is the same as `gte`, but the result is undefined if either operand is not a valid u32 value. - pub fn gte_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedGte); - } - - /// This is the same as `min`, but also asserts that both operands are valid u32 values. + /// Computes the minimum of the two elements on top of the stack. + /// + /// The result is undefined if either operand is not a valid u32 value. pub fn min_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedMin); + self.build(self.ip, MasmOp::U32Min); } - /// This is the same as `min`, but the result is undefined if either operand is not a valid u32 value. - pub fn min_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedMin); - } - - /// This is the same as `max`, but also asserts that both operands are valid u32 values. + /// Computes the maximum of the two elements on top of the stack. + /// + /// The result is undefined if either operand is not a valid u32 value. pub fn max_u32(mut self) { - self.build(self.ip, MasmOp::U32CheckedMax); - } - - /// This is the same as `max`, but the result is undefined if either operand is not a valid u32 value. - pub fn max_unchecked_u32(mut self) { - self.build(self.ip, MasmOp::U32UncheckedMax); + self.build(self.ip, MasmOp::U32Max); } #[inline(never)] @@ -1130,6 +1069,14 @@ impl<'a> MasmOpBuilder<'a> { apply_op_stack_effects(&op, self.stack, self.dfg, self.asm); self.asm.push(ip, op); } + + #[inline(never)] + fn build_many(&mut self, ip: MasmBlockId, ops: impl IntoIterator) { + for op in ops.into_iter() { + apply_op_stack_effects(&op, self.stack, self.dfg, self.asm); + self.asm.push(ip, op); + } + } } #[doc(hidden)] @@ -1535,6 +1482,26 @@ macro_rules! assert_compatible_u32_operands { }; } +/// Asserts that the given value is an integer or pointer type which is compatible with basic felt arithmetic +macro_rules! assert_compatible_arithmetic_operand { + ($ty:ident) => { + assert!( + $ty.is_pointer() || Type::Felt.is_compatible_operand(&$ty), + "expected operand to be felt-compatible, got {}", + $ty + ); + }; + + ($ty:ident, $op:expr) => { + assert!( + $ty.is_pointer() || Type::Felt.is_compatible_operand(&$ty), + "expected operand for {} to be felt-compatible, got {}", + $op, + $ty + ); + }; +} + /// Asserts that the given value is an integer type which is compatible with felt operations macro_rules! assert_compatible_felt_operand { ($ty:ident) => { @@ -1555,6 +1522,45 @@ macro_rules! assert_compatible_felt_operand { }; } +/// Asserts that the given value is an integer or pointer type which is compatible with basic +/// arithmetic operations as a felt +macro_rules! assert_compatible_arithmetic_operands { + ($lty:ident, $rty:ident) => { + assert_matches!( + $lty, + Type::U8 + | Type::I8 + | Type::U16 + | Type::I16 + | Type::U32 + | Type::I32 + | Type::Ptr(_) + | Type::Felt, + "expected controlling type to be felt-compatible, got {}", + $lty + ); + assert_compatible_operand_types!($lty, $rty); + }; + + ($lty:ident, $rty:ident, $op:expr) => { + assert_matches!( + $lty, + Type::U8 + | Type::I8 + | Type::U16 + | Type::I16 + | Type::U32 + | Type::I32 + | Type::Ptr(_) + | Type::Felt, + "expected controlling type for {} to be felt-compatible, got {}", + $op, + $lty + ); + assert_compatible_operand_types!($lty, $rty, $op); + }; +} + /// Asserts that the given value is an integer type which is compatible with felt operations macro_rules! assert_compatible_felt_operands { ($lty:ident, $rty:ident) => { @@ -1663,13 +1669,16 @@ fn apply_op_stack_effects( assert_eq!(ty, Type::I1, "expected boolean operand on top of the stack"); stack.dropw(); } - MasmOp::Assert | MasmOp::Assertz => { + MasmOp::Assert + | MasmOp::Assertz + | MasmOp::AssertWithError(_) + | MasmOp::AssertzWithError(_) => { stack.drop(); } - MasmOp::AssertEq => { + MasmOp::AssertEq | MasmOp::AssertEqWithError(_) => { stack.dropn(2); } - MasmOp::AssertEqw => { + MasmOp::AssertEqw | MasmOp::AssertEqwWithError(_) => { stack.dropn(8); } MasmOp::LocAddr(_id) | MasmOp::LocStore(_id) | MasmOp::LocStorew(_id) => unreachable!(), @@ -1724,6 +1733,47 @@ fn apply_op_stack_effects( MasmOp::MemStorewImm(_) => { stack.dropw(); } + MasmOp::MemStream => { + // Read two sequential words from memory starting at `a`, overwriting the first two words on the stack, + // and advancing `a` to the next address following the two that were loaded + // [C, B, A, a] <- [*a, *(a + 1), A, a + 2] + assert!( + stack.len() > 12, + "expected at least 13 elements on the stack for mem_stream" + ); + stack.dropw(); + stack.dropw(); + stack.padw(); + stack.padw(); + } + MasmOp::AdvPipe => { + // Pops the next two words from the advice stack, overwrites the + // top of the operand stack with them, and also writes these words + // into memory at `a` and `a + 1` + // + // [C, B, A, a] <- [*a, *(a + 1), A, a + 2] + assert!( + stack.len() > 12, + "expected at least 13 elements on the stack for mem_stream" + ); + stack.dropw(); + stack.dropw(); + stack.padw(); + stack.padw(); + } + MasmOp::AdvPush(n) => { + for _ in 0..(*n) { + stack.push(Type::Felt); + } + } + MasmOp::AdvLoadw => { + assert!( + stack.len() > 3, + "expected at least 4 elements on the stack for mem_stream" + ); + stack.dropw(); + stack.padw(); + } // This function is not called from [MasmOpBuilder] when building an `if.true` instruction, // instead, the only time we are evaluating this is when traversing the body of a `repeat.n` // instruction and applying the stack effects of instructions which have already been inserted @@ -1768,19 +1818,35 @@ fn apply_op_stack_effects( MasmOp::Syscall(ref id) => { execute_call(id, false, stack, dfg); } - MasmOp::Add | MasmOp::Sub | MasmOp::Mul | MasmOp::Div => { + MasmOp::DynExec | MasmOp::DynCall => { + assert!( + stack.len() > 3, + "expected at least 4 elements on the stack for dynexec/dyncall" + ); + } + MasmOp::ProcRef(_) => { + stack.pushw([Type::Felt, Type::Felt, Type::Felt, Type::Felt]); + } + MasmOp::Add | MasmOp::Sub => { + let rty = stack.pop().expect("operand stack is empty"); + let lty = stack.pop().expect("operand stack is empty"); + assert_compatible_arithmetic_operands!(lty, rty, op); + stack.push(lty); + } + MasmOp::Mul | MasmOp::Div => { let rty = stack.pop().expect("operand stack is empty"); let lty = stack.pop().expect("operand stack is empty"); assert_compatible_felt_operands!(lty, rty, op); stack.push(lty); } - MasmOp::AddImm(_) - | MasmOp::SubImm(_) - | MasmOp::MulImm(_) + MasmOp::AddImm(_) | MasmOp::SubImm(_) | MasmOp::Incr => { + let ty = stack.peek().expect("operand stack is empty"); + assert_compatible_arithmetic_operand!(ty, op); + } + MasmOp::MulImm(_) | MasmOp::DivImm(_) | MasmOp::Neg | MasmOp::Inv - | MasmOp::Incr | MasmOp::Pow2 | MasmOp::ExpImm(_) => { let ty = stack.peek().expect("operand stack is empty"); @@ -1828,6 +1894,14 @@ fn apply_op_stack_effects( MasmOp::Clk => { stack.push(Type::Felt); } + MasmOp::Caller => { + assert!( + stack.len() > 3, + "expected at least 4 elements on the operand stack" + ); + stack.popw(); + stack.pushw([Type::Felt, Type::Felt, Type::Felt, Type::Felt]); + } MasmOp::U32Test => { assert!(!stack.is_empty()); stack.push(Type::I1); @@ -1839,16 +1913,16 @@ fn apply_op_stack_effects( ); stack.push(Type::I1); } - MasmOp::U32Assert => { + MasmOp::U32Assert | MasmOp::U32AssertWithError(_) => { assert!(!stack.is_empty()); } - MasmOp::U32Assert2 => { + MasmOp::U32Assert2 | MasmOp::U32Assert2WithError(_) => { assert!( stack.len() > 1, "expected at least 2 elements on the operand stack" ); } - MasmOp::U32Assertw => { + MasmOp::U32Assertw | MasmOp::U32AssertwWithError(_) => { assert!( stack.len() > 3, "expected at least 4 elements on the operand stack" @@ -1865,30 +1939,24 @@ fn apply_op_stack_effects( stack.push(Type::U32); stack.push(Type::U32); } - MasmOp::U32CheckedAdd - | MasmOp::U32CheckedSub - | MasmOp::U32CheckedMul - | MasmOp::U32CheckedDiv - | MasmOp::U32CheckedMod - | MasmOp::U32CheckedDivMod - | MasmOp::U32CheckedShl - | MasmOp::U32CheckedShr - | MasmOp::U32CheckedRotl - | MasmOp::U32CheckedRotr - | MasmOp::U32CheckedMin - | MasmOp::U32CheckedMax + MasmOp::U32Lt | MasmOp::U32Gt | MasmOp::U32Lte | MasmOp::U32Gte => { + let rty = stack.pop().expect("failed to pop right operand: stack is empty"); + let lty = stack.pop().expect("failed to pop left operand: stack is empty"); + assert_compatible_u32_operands!(lty, rty, op); + stack.push(Type::I1); + } + MasmOp::U32Div + | MasmOp::U32Mod + | MasmOp::U32DivMod + | MasmOp::U32Shl + | MasmOp::U32Shr + | MasmOp::U32Rotl + | MasmOp::U32Rotr + | MasmOp::U32Min + | MasmOp::U32Max | MasmOp::U32WrappingAdd | MasmOp::U32WrappingSub | MasmOp::U32WrappingMul - | MasmOp::U32UncheckedDiv - | MasmOp::U32UncheckedMod - | MasmOp::U32UncheckedDivMod - | MasmOp::U32UncheckedShl - | MasmOp::U32UncheckedShr - | MasmOp::U32UncheckedRotl - | MasmOp::U32UncheckedRotr - | MasmOp::U32UncheckedMin - | MasmOp::U32UncheckedMax | MasmOp::U32And | MasmOp::U32Or | MasmOp::U32Xor => { @@ -1897,28 +1965,17 @@ fn apply_op_stack_effects( assert_compatible_u32_operands!(lty, rty, op); stack.push(lty); } - MasmOp::U32CheckedAddImm(_) - | MasmOp::U32CheckedSubImm(_) - | MasmOp::U32CheckedMulImm(_) - | MasmOp::U32CheckedDivImm(_) - | MasmOp::U32CheckedModImm(_) - | MasmOp::U32CheckedDivModImm(_) - | MasmOp::U32CheckedShlImm(_) - | MasmOp::U32CheckedShrImm(_) - | MasmOp::U32CheckedRotlImm(_) - | MasmOp::U32CheckedRotrImm(_) - | MasmOp::U32CheckedPopcnt + MasmOp::U32DivImm(_) + | MasmOp::U32ModImm(_) + | MasmOp::U32DivModImm(_) + | MasmOp::U32ShlImm(_) + | MasmOp::U32ShrImm(_) + | MasmOp::U32RotlImm(_) + | MasmOp::U32RotrImm(_) + | MasmOp::U32Popcnt | MasmOp::U32WrappingAddImm(_) | MasmOp::U32WrappingSubImm(_) | MasmOp::U32WrappingMulImm(_) - | MasmOp::U32UncheckedDivImm(_) - | MasmOp::U32UncheckedModImm(_) - | MasmOp::U32UncheckedDivModImm(_) - | MasmOp::U32UncheckedShlImm(_) - | MasmOp::U32UncheckedShrImm(_) - | MasmOp::U32UncheckedRotlImm(_) - | MasmOp::U32UncheckedRotrImm(_) - | MasmOp::U32UncheckedPopcnt | MasmOp::U32Not => { let ty = stack.pop().expect("operand stack is empty"); assert_compatible_u32_operand!(ty, op); @@ -1973,34 +2030,6 @@ fn apply_op_stack_effects( assert_compatible_u32_operands!(aty, cty); stack.push(aty); } - MasmOp::U32Eq - | MasmOp::U32Neq - | MasmOp::U32CheckedLt - | MasmOp::U32CheckedLte - | MasmOp::U32CheckedGt - | MasmOp::U32CheckedGte - | MasmOp::U32UncheckedLt - | MasmOp::U32UncheckedLte - | MasmOp::U32UncheckedGt - | MasmOp::U32UncheckedGte => { - let rty = stack.pop().expect("operand stack is empty"); - let lty = stack.pop().expect("operand stack is empty"); - // We support pointer operands for these operators, but unlike - // other u32 ops, both operands may be pointer values, so we - // handle that here by checking compatiblity separately - if lty.is_pointer() { - assert_compatible_u32_operand!(rty, op); - stack.push(Type::I1); - } else { - assert_compatible_u32_operands!(lty, rty, op); - stack.push(Type::I1); - } - } - MasmOp::U32EqImm(_) | MasmOp::U32NeqImm(_) => { - let ty = stack.pop().expect("operand stack is empty"); - assert_compatible_u32_operand!(ty, op); - stack.push(Type::I1); - } } } diff --git a/hir/src/asm/display.rs b/hir/src/asm/display.rs index bade3775e..4f19de8c4 100644 --- a/hir/src/asm/display.rs +++ b/hir/src/asm/display.rs @@ -139,6 +139,9 @@ impl<'a> fmt::Display for DisplayOp<'a> { | MasmOp::MemStoreOffsetImm(addr, offset)) => { write!(f, "{op}.{}.{offset}", Address(*addr)) } + op @ MasmOp::AdvPush(n) => { + write!(f, "{op}.{n}") + } MasmOp::If(then_blk, else_blk) => { write!( f, @@ -185,20 +188,13 @@ impl<'a> fmt::Display for DisplayOp<'a> { DisplayIndent(self.indent), ) } - MasmOp::Exec(FunctionIdent { module, function }) => { - if self.is_local_module(module) { - write!(f, "exec.{function}") - } else { - let alias = self.get_module_alias(*module); - write!(f, "exec.{alias}::{function}") - } - } - MasmOp::Syscall(FunctionIdent { module, function }) => { + op @ (MasmOp::Exec(id) | MasmOp::Syscall(id) | MasmOp::ProcRef(id)) => { + let FunctionIdent { module, function } = id; if self.is_local_module(module) { - write!(f, "syscall.{function}") + write!(f, "{op}.{function}") } else { let alias = self.get_module_alias(*module); - write!(f, "syscall.{alias}::{function}") + write!(f, "{op}.{alias}::{function}") } } op @ (MasmOp::AndImm(imm) | MasmOp::OrImm(imm) | MasmOp::XorImm(imm)) => { @@ -215,31 +211,19 @@ impl<'a> fmt::Display for DisplayOp<'a> { | MasmOp::GteImm(imm) | MasmOp::LtImm(imm) | MasmOp::LteImm(imm)) => write!(f, "{op}.{imm}"), - op @ (MasmOp::U32CheckedAddImm(imm) - | MasmOp::U32OverflowingAddImm(imm) + op @ (MasmOp::U32OverflowingAddImm(imm) | MasmOp::U32WrappingAddImm(imm) - | MasmOp::U32CheckedSubImm(imm) | MasmOp::U32OverflowingSubImm(imm) | MasmOp::U32WrappingSubImm(imm) - | MasmOp::U32CheckedMulImm(imm) | MasmOp::U32OverflowingMulImm(imm) | MasmOp::U32WrappingMulImm(imm) - | MasmOp::U32CheckedDivImm(imm) - | MasmOp::U32UncheckedDivImm(imm) - | MasmOp::U32CheckedModImm(imm) - | MasmOp::U32UncheckedModImm(imm) - | MasmOp::U32CheckedDivModImm(imm) - | MasmOp::U32UncheckedDivModImm(imm) - | MasmOp::U32CheckedShlImm(imm) - | MasmOp::U32UncheckedShlImm(imm) - | MasmOp::U32CheckedShrImm(imm) - | MasmOp::U32UncheckedShrImm(imm) - | MasmOp::U32CheckedRotlImm(imm) - | MasmOp::U32UncheckedRotlImm(imm) - | MasmOp::U32CheckedRotrImm(imm) - | MasmOp::U32UncheckedRotrImm(imm) - | MasmOp::U32EqImm(imm) - | MasmOp::U32NeqImm(imm)) => write!(f, "{op}.{imm}"), + | MasmOp::U32DivImm(imm) + | MasmOp::U32ModImm(imm) + | MasmOp::U32DivModImm(imm) + | MasmOp::U32ShlImm(imm) + | MasmOp::U32ShrImm(imm) + | MasmOp::U32RotlImm(imm) + | MasmOp::U32RotrImm(imm)) => write!(f, "{op}.{imm}"), op => write!(f, "{op}"), } } diff --git a/hir/src/asm/isa.rs b/hir/src/asm/isa.rs index 042ca5e57..dd6392670 100644 --- a/hir/src/asm/isa.rs +++ b/hir/src/asm/isa.rs @@ -162,12 +162,20 @@ pub enum MasmOp { Cdropw, /// Pops a value off the stack and asserts that it is equal to 1 Assert, + /// Pops a value off the stack and asserts that it is equal to 1, raising the given error code + AssertWithError(u32), /// Pops a value off the stack and asserts that it is equal to 0 Assertz, + /// Pops a value off the stack and asserts that it is equal to 0, raising the given error code + AssertzWithError(u32), /// Pops two values off the stack and asserts that they are equal AssertEq, + /// Pops two values off the stack and asserts that they are equal, raising the given error code + AssertEqWithError(u32), /// Pops two words off the stack and asserts that they are equal AssertEqw, + /// Pops two words off the stack and asserts that they are equal, raising the given error code + AssertEqwWithError(u32), /// Places the memory address of the given local index on top of the stack LocAddr(LocalId), /// Writes a value to the first element of the word at the address corresponding to the given local index @@ -225,6 +233,20 @@ pub enum MasmOp { MemStorew, /// Same as above, but the address is given as an immediate MemStorewImm(u32), + /// Read two sequential words from memory starting at `a`, overwriting the first two words on the stack, + /// and advancing `a` to the next address following the two that were loaded + /// [C, B, A, a] <- [*a, *(a + 1), A, a + 2] + MemStream, + /// Pops the next two words from the advice stack, overwrites the + /// top of the operand stack with them, and also writes these words + /// into memory at `a` and `a + 1` + /// + /// [C, B, A, a] <- [*a, *(a + 1), A, a + 2] + AdvPipe, + /// TODO + AdvPush(u8), + /// TODO + AdvLoadw, /// Pops the top of the stack, and evaluates the ops in /// the block of code corresponding to the branch taken. /// @@ -244,6 +266,12 @@ pub enum MasmOp { Exec(FunctionIdent), /// Pops `N` args off the stack, executes the procedure in the root context, results will be placed on the stack Syscall(FunctionIdent), + /// Pops the address (MAST root hash) of a callee off the stack, and dynamically `exec` the function + DynExec, + /// TODO + DynCall, + /// Pushes the address (MAST root hash) of the given function on the stack, to be used by `dynexec` or `dyncall` + ProcRef(FunctionIdent), /// Pops `b, a` off the stack, and places the result of `(a + b) mod p` on the stack Add, /// Same as above, but the immediate is used for `b` @@ -341,6 +369,8 @@ pub enum MasmOp { /// /// The comparison works by comparing pairs of elements from each word Eqw, + /// When called via `syscall`, this pushes the hash of the caller's MAST root on the stack + Caller, /// Pushes the current value of the cycle counter (clock) on the stack Clk, /// Peeks `a` from the top of the stack, and places the 1 on the stack if `a < 2^32`, else 0 @@ -349,10 +379,16 @@ pub enum MasmOp { U32Testw, /// Peeks `a` from the top of the stack, and traps if `a >= 2^32` U32Assert, + /// Peeks `a` from the top of the stack, and traps if `a >= 2^32`, raising the given error code + U32AssertWithError(u32), /// Peeks `b, a` from the top of the stack, and traps if either `a` or `b` is >= 2^32 U32Assert2, + /// Peeks `b, a` from the top of the stack, and traps if either `a` or `b` is >= 2^32, raising the given error code + U32Assert2WithError(u32), /// Peeks `A` from the top of the stack, and traps unless `forall a : A, a < 2^32`, else 0 U32Assertw, + /// Peeks `A` from the top of the stack, and traps unless `forall a : A, a < 2^32`, else 0, raising the given error code + U32AssertwWithError(u32), /// Pops `a` from the top of the stack, and places the result of `a mod 2^32` on the stack /// /// This is used to cast a field element to the u32 range @@ -361,11 +397,6 @@ pub enum MasmOp { /// placing them back on the stack. The lower part is calculated as `a mod 2^32`, /// and the higher part as `a / 2^32`. The higher part will be on top of the stack after. U32Split, - /// Pops `b, a` from the stack, and places the result of `a + b` on the stack, - /// trapping if the result, or either operand, are >= 2^32 - U32CheckedAdd, - /// Same as above, but with `b` provided by the immediate - U32CheckedAddImm(u32), /// Pops `b, a` from the stack, and places the result of `(a + b) mod 2^32` on the stack, /// followed by 1 if `(a + b) >= 2^32`, else 0. Thus the first item on the stack will be /// a boolean indicating whether the arithmetic overflowed, and the second will be the @@ -393,11 +424,6 @@ pub enum MasmOp { /// /// The behavior is undefined if any of `c`, `b` or `a` are >= 2^32 U32WrappingAdd3, - /// Pops `b, a` from the stack, and places the result of `a - b` on the stack, - /// trapping if the result, or either operand, are >= 2^32; OR if `a < b`. - U32CheckedSub, - /// Same as above, but with `b` provided by the immediate - U32CheckedSubImm(u32), /// Pops `b, a` from the stack, and places the result of `(a - b) mod 2^32` on the stack, /// followed by 1 if `a < b`, else 0. Thus the first item on the stack will be /// a boolean indicating whether the arithmetic underflowed, and the second will be the @@ -413,11 +439,6 @@ pub enum MasmOp { U32WrappingSub, /// Same as above, but with `b` provided by the immediate U32WrappingSubImm(u32), - /// Pops `b, a` from the stack, and places the result of `a * b` on the stack, - /// trapping if the result, or either operand, are >= 2^32. - U32CheckedMul, - /// Same as above, but with `b` provided by the immediate - U32CheckedMulImm(u32), /// Pops `b, a` from the stack, and places the result of `(a * b) mod 2^32` on the stack, /// followed by `(a * b) / 2^32`. Thus the first item on the stack will be the number /// of times the multiplication overflowed, followed by the result. @@ -444,46 +465,28 @@ pub enum MasmOp { U32WrappingMadd, /// Pops `b, a` off the stack, and pushes `a / b` on the stack. /// - /// Traps if `b` is 0, or if `a` or `b` >= 2^32 - U32CheckedDiv, - /// Same as above, except `b` is provided by the immediate - U32CheckedDivImm(u32), - /// Pops `b, a` off the stack, and pushes `a / b` on the stack. - /// - /// Traps if `b` is 0. + /// This operation traps if `b` is zero. /// - /// Behavior is undefined if `a` or `b` >= 2^32 - U32UncheckedDiv, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Div, /// Same as above, except `b` is provided by the immediate - U32UncheckedDivImm(u32), + U32DivImm(u32), /// Pops `b, a` off the stack, and pushes `a mod b` on the stack. /// - /// Traps if `b` is 0, or if `a` or `b` >= 2^32 - U32CheckedMod, - /// Same as above, except `b` is provided by the immediate - U32CheckedModImm(u32), - /// Pops `b, a` off the stack, and pushes `a mod b` on the stack. + /// This operation traps if `b` is zero. /// - /// Traps if `b` is 0. - /// - /// Behavior is undefined if `a` or `b` >= 2^32 - U32UncheckedMod, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Mod, /// Same as above, except `b` is provided by the immediate - U32UncheckedModImm(u32), + U32ModImm(u32), /// Pops `b, a` off the stack, and first pushes `a / b` on the stack, followed by `a mod b`. /// - /// Traps if `b` is 0, or if `a` or `b` >= 2^32 - U32CheckedDivMod, - /// Same as above, except `b` is provided by the immediate - U32CheckedDivModImm(u32), - /// Pops `b, a` off the stack, and first pushes `a / b` on the stack, followed by `a mod b`. - /// - /// Traps if `b` is 0. + /// This operation traps if `b` is zero. /// - /// Behavior is undefined if `a` or `b` >= 2^32 - U32UncheckedDivMod, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32DivMod, /// Same as above, except `b` is provided by the immediate - U32UncheckedDivModImm(u32), + U32DivModImm(u32), /// Pops `b, a` off the stack, and places the bitwise AND of `a` and `b` on the stack. /// /// Traps if either `a` or `b` >= 2^32 @@ -502,124 +505,62 @@ pub enum MasmOp { U32Not, /// Pops `b, a` off the stack, and places the result of `(a * 2^b) mod 2^32` on the stack. /// - /// Traps if `a >= 2^32` or `b > 31` - U32CheckedShl, - /// Same as above, except `b` is provided by the immediate - U32CheckedShlImm(u32), - /// Pops `b, a` off the stack, and places the result of `(a * 2^b) mod 2^32` on the stack. + /// Truncates if the shift would cause overflow. /// - /// Behavior is undefined if `a >= 2^32` or `b > 31` - U32UncheckedShl, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Shl, /// Same as above, except `b` is provided by the immediate - U32UncheckedShlImm(u32), + U32ShlImm(u32), /// Pops `b, a` off the stack, and places the result of `a / 2^b` on the stack. /// - /// Traps if `a >= 2^32` or `b > 31` - U32CheckedShr, - /// Same as above, except `b` is provided by the immediate - U32CheckedShrImm(u32), - /// Pops `b, a` off the stack, and places the result of `a / 2^b` on the stack. + /// Truncates if the shift would cause overflow. /// - /// Behavior is undefined if `a >= 2^32` or `b > 31` - U32UncheckedShr, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Shr, /// Same as above, except `b` is provided by the immediate - U32UncheckedShrImm(u32), + U32ShrImm(u32), /// Pops `b, a` off the stack, and places the result of rotating the 32-bit /// representation of `a` to the left by `b` bits. /// - /// Traps if `a` >= 2^32, or `b` > 31 - U32CheckedRotl, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Rotl, /// Same as above, except `b` is provided by the immediate - U32CheckedRotlImm(u32), - /// Pops `b, a` off the stack, and places the result of rotating the 32-bit - /// representation of `a` to the left by `b` bits. - /// - /// Behavior is undefined if `a` >= 2^32, or `b` > 31 - U32UncheckedRotl, - /// Same as above, except `b` is provided by the immediate - U32UncheckedRotlImm(u32), - /// Pops `b, a` off the stack, and places the result of rotating the 32-bit - /// representation of `a` to the right by `b` bits. - /// - /// Traps if `a` >= 2^32, or `b` > 31 - U32CheckedRotr, - /// Same as above, except `b` is provided by the immediate - U32CheckedRotrImm(u32), + U32RotlImm(u32), /// Pops `b, a` off the stack, and places the result of rotating the 32-bit /// representation of `a` to the right by `b` bits. /// - /// Behavior is undefined if `a` >= 2^32, or `b` > 31 - U32UncheckedRotr, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Rotr, /// Same as above, except `b` is provided by the immediate - U32UncheckedRotrImm(u32), + U32RotrImm(u32), /// Pops `a` off the stack, and places the number of set bits in `a` (it's hamming weight). /// - /// Traps if `a` >= 2^32 - U32CheckedPopcnt, - /// Pops `a` off the stack, and places the number of set bits in `a` (it's hamming weight). - /// - /// Behavior is undefined if `a` >= 2^32 - U32UncheckedPopcnt, - /// Pops `b, a` from the stack, and places 1 on the stack if `a == b`, else 0 - /// - /// Traps if either `a` or `b` are >= 2^32 - U32Eq, - /// Same as above, except `b` is provided by the immediate - U32EqImm(u32), - /// Pops `b, a` from the stack, and places 1 on the stack if `a != b`, else 0 - /// - /// Traps if either `a` or `b` are >= 2^32 - U32Neq, - /// Same as above, except `b` is provided by the immediate - U32NeqImm(u32), - /// Pops `b, a` from the stack, and places 1 on the stack if `a < b`, else 0 - /// - /// Traps if either `a` or `b` are >= 2^32 - U32CheckedLt, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Popcnt, /// Pops `b, a` from the stack, and places 1 on the stack if `a < b`, else 0 /// - /// The behavior is undefined if either `a` or `b` are >= 2^32 - U32UncheckedLt, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Lt, /// Pops `b, a` from the stack, and places 1 on the stack if `a <= b`, else 0 /// - /// Traps if either `a` or `b` are >= 2^32 - U32CheckedLte, - /// Pops `b, a` from the stack, and places 1 on the stack if `a <= b`, else 0 - /// - /// The behavior is undefined if either `a` or `b` are >= 2^32 - U32UncheckedLte, - /// Pops `b, a` from the stack, and places 1 on the stack if `a > b`, else 0 - /// - /// Traps if either `a` or `b` are >= 2^32 - U32CheckedGt, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Lte, /// Pops `b, a` from the stack, and places 1 on the stack if `a > b`, else 0 /// - /// The behavior is undefined if either `a` or `b` are >= 2^32 - U32UncheckedGt, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Gt, /// Pops `b, a` from the stack, and places 1 on the stack if `a >= b`, else 0 /// - /// Traps if either `a` or `b` are >= 2^32 - U32CheckedGte, - /// Pops `b, a` from the stack, and places 1 on the stack if `a >= b`, else 0 - /// - /// The behavior is undefined if either `a` or `b` are >= 2^32 - U32UncheckedGte, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Gte, /// Pops `b, a` from the stack, and places `a` back on the stack if `a < b`, else `b` /// - /// Traps if either `a` or `b` are >= 2^32 - U32CheckedMin, - /// Pops `b, a` from the stack, and places `a` back on the stack if `a < b`, else `b` - /// - /// The behavior is undefined if either `a` or `b` are >= 2^32 - U32UncheckedMin, - /// Pops `b, a` from the stack, and places `a` back on the stack if `a > b`, else `b` - /// - /// Traps if either `a` or `b` are >= 2^32 - U32CheckedMax, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Min, /// Pops `b, a` from the stack, and places `a` back on the stack if `a > b`, else `b` /// - /// The behavior is undefined if either `a` or `b` are >= 2^32 - U32UncheckedMax, + /// This operation is unchecked, so the result is undefined if the operands are not valid u32 + U32Max, } impl MasmOp { pub fn from_masm( @@ -632,17 +573,13 @@ impl MasmOp { let op = match ix { Instruction::Assert => Self::Assert, - // TODO: Handle assertion error code when support is added to the IR - Instruction::AssertWithError(_) => Self::Assert, + Instruction::AssertWithError(code) => Self::AssertWithError(code), Instruction::AssertEq => Self::AssertEq, - // TODO: Handle assertion error code when support is added to the IR - Instruction::AssertEqWithError(_) => Self::AssertEq, + Instruction::AssertEqWithError(code) => Self::AssertEqWithError(code), Instruction::AssertEqw => Self::AssertEqw, - // TODO: Handle assertion error code when support is added to the IR - Instruction::AssertEqwWithError(_) => Self::AssertEqw, + Instruction::AssertEqwWithError(code) => Self::AssertEqwWithError(code), Instruction::Assertz => Self::Assertz, - // TODO: Handle assertion error code when support is added to the IR - Instruction::AssertzWithError(_) => Self::Assertz, + Instruction::AssertzWithError(code) => Self::AssertzWithError(code), Instruction::Add => Self::Add, Instruction::AddImm(imm) => Self::AddImm(imm), Instruction::Sub => Self::Sub, @@ -683,88 +620,54 @@ impl MasmOp { Instruction::U32Test => Self::U32Test, Instruction::U32TestW => Self::U32Testw, Instruction::U32Assert => Self::U32Assert, - // TODO: Handle assertion error code when support is added to the IR - Instruction::U32AssertWithError(_) => Self::U32Assert, + Instruction::U32AssertWithError(code) => Self::U32AssertWithError(code), Instruction::U32Assert2 => Self::U32Assert2, - // TODO: Handle assertion error code when support is added to the IR - Instruction::U32Assert2WithError(_) => Self::U32Assert2, + Instruction::U32Assert2WithError(code) => Self::U32Assert2WithError(code), Instruction::U32AssertW => Self::U32Assertw, - // TODO: Handle assertion error code when support is added to the IR - Instruction::U32AssertWWithError(_) => Self::U32Assertw, + Instruction::U32AssertWWithError(code) => Self::U32AssertwWithError(code), Instruction::U32Split => Self::U32Split, Instruction::U32Cast => Self::U32Cast, - Instruction::U32CheckedAdd => Self::U32CheckedAdd, - Instruction::U32CheckedAddImm(imm) => Self::U32CheckedAddImm(imm), Instruction::U32WrappingAdd => Self::U32WrappingAdd, Instruction::U32WrappingAddImm(imm) => Self::U32WrappingAddImm(imm), Instruction::U32OverflowingAdd => Self::U32OverflowingAdd, Instruction::U32OverflowingAddImm(imm) => Self::U32OverflowingAddImm(imm), Instruction::U32OverflowingAdd3 => Self::U32OverflowingAdd3, Instruction::U32WrappingAdd3 => Self::U32WrappingAdd3, - Instruction::U32CheckedSub => Self::U32CheckedSub, - Instruction::U32CheckedSubImm(imm) => Self::U32CheckedSubImm(imm), Instruction::U32WrappingSub => Self::U32WrappingSub, Instruction::U32WrappingSubImm(imm) => Self::U32WrappingSubImm(imm), Instruction::U32OverflowingSub => Self::U32OverflowingSub, Instruction::U32OverflowingSubImm(imm) => Self::U32OverflowingSubImm(imm), - Instruction::U32CheckedMul => Self::U32CheckedMul, - Instruction::U32CheckedMulImm(imm) => Self::U32CheckedMulImm(imm), Instruction::U32WrappingMul => Self::U32WrappingMul, Instruction::U32WrappingMulImm(imm) => Self::U32WrappingMulImm(imm), Instruction::U32OverflowingMul => Self::U32OverflowingMul, Instruction::U32OverflowingMulImm(imm) => Self::U32OverflowingMulImm(imm), Instruction::U32OverflowingMadd => Self::U32OverflowingMadd, Instruction::U32WrappingMadd => Self::U32WrappingMadd, - Instruction::U32CheckedDiv => Self::U32CheckedDiv, - Instruction::U32CheckedDivImm(imm) => Self::U32CheckedDivImm(imm), - Instruction::U32UncheckedDiv => Self::U32UncheckedDiv, - Instruction::U32UncheckedDivImm(imm) => Self::U32UncheckedDivImm(imm), - Instruction::U32CheckedMod => Self::U32CheckedMod, - Instruction::U32CheckedModImm(imm) => Self::U32CheckedModImm(imm), - Instruction::U32UncheckedMod => Self::U32UncheckedMod, - Instruction::U32UncheckedModImm(imm) => Self::U32UncheckedModImm(imm), - Instruction::U32CheckedDivMod => Self::U32CheckedDivMod, - Instruction::U32CheckedDivModImm(imm) => Self::U32CheckedDivModImm(imm), - Instruction::U32UncheckedDivMod => Self::U32UncheckedDivMod, - Instruction::U32UncheckedDivModImm(imm) => Self::U32UncheckedDivModImm(imm), - Instruction::U32CheckedAnd => Self::U32And, - Instruction::U32CheckedOr => Self::U32Or, - Instruction::U32CheckedXor => Self::U32Xor, - Instruction::U32CheckedNot => Self::U32Not, - Instruction::U32CheckedShr => Self::U32CheckedShr, - Instruction::U32CheckedShrImm(imm) => Self::U32CheckedShrImm(imm as u32), - Instruction::U32UncheckedShr => Self::U32UncheckedShr, - Instruction::U32UncheckedShrImm(imm) => Self::U32UncheckedShrImm(imm as u32), - Instruction::U32CheckedShl => Self::U32CheckedShl, - Instruction::U32CheckedShlImm(imm) => Self::U32CheckedShlImm(imm as u32), - Instruction::U32UncheckedShl => Self::U32UncheckedShl, - Instruction::U32UncheckedShlImm(imm) => Self::U32UncheckedShlImm(imm as u32), - Instruction::U32CheckedRotr => Self::U32CheckedRotr, - Instruction::U32CheckedRotrImm(imm) => Self::U32CheckedRotrImm(imm as u32), - Instruction::U32UncheckedRotr => Self::U32UncheckedRotr, - Instruction::U32UncheckedRotrImm(imm) => Self::U32UncheckedRotrImm(imm as u32), - Instruction::U32CheckedRotl => Self::U32CheckedRotl, - Instruction::U32CheckedRotlImm(imm) => Self::U32CheckedRotlImm(imm as u32), - Instruction::U32UncheckedRotl => Self::U32UncheckedRotl, - Instruction::U32UncheckedRotlImm(imm) => Self::U32UncheckedRotlImm(imm as u32), - Instruction::U32CheckedPopcnt => Self::U32CheckedPopcnt, - Instruction::U32UncheckedPopcnt => Self::U32UncheckedPopcnt, - Instruction::U32CheckedEq => Self::U32Eq, - Instruction::U32CheckedEqImm(imm) => Self::U32EqImm(imm), - Instruction::U32CheckedNeq => Self::U32Neq, - Instruction::U32CheckedNeqImm(imm) => Self::U32NeqImm(imm), - Instruction::U32CheckedLt => Self::U32CheckedLt, - Instruction::U32UncheckedLt => Self::U32UncheckedLt, - Instruction::U32CheckedLte => Self::U32CheckedLte, - Instruction::U32UncheckedLte => Self::U32UncheckedLte, - Instruction::U32CheckedGt => Self::U32CheckedGt, - Instruction::U32UncheckedGt => Self::U32UncheckedGt, - Instruction::U32CheckedGte => Self::U32CheckedGte, - Instruction::U32UncheckedGte => Self::U32UncheckedGte, - Instruction::U32CheckedMin => Self::U32CheckedMin, - Instruction::U32UncheckedMin => Self::U32UncheckedMin, - Instruction::U32CheckedMax => Self::U32CheckedMax, - Instruction::U32UncheckedMax => Self::U32UncheckedMax, + Instruction::U32Div => Self::U32Div, + Instruction::U32DivImm(imm) => Self::U32DivImm(imm), + Instruction::U32Mod => Self::U32Mod, + Instruction::U32ModImm(imm) => Self::U32ModImm(imm), + Instruction::U32DivMod => Self::U32DivMod, + Instruction::U32DivModImm(imm) => Self::U32DivModImm(imm), + Instruction::U32And => Self::U32And, + Instruction::U32Or => Self::U32Or, + Instruction::U32Xor => Self::U32Xor, + Instruction::U32Not => Self::U32Not, + Instruction::U32Shr => Self::U32Shr, + Instruction::U32ShrImm(imm) => Self::U32ShrImm(imm as u32), + Instruction::U32Shl => Self::U32Shl, + Instruction::U32ShlImm(imm) => Self::U32ShlImm(imm as u32), + Instruction::U32Rotr => Self::U32Rotr, + Instruction::U32RotrImm(imm) => Self::U32RotrImm(imm as u32), + Instruction::U32Rotl => Self::U32Rotl, + Instruction::U32RotlImm(imm) => Self::U32RotlImm(imm as u32), + Instruction::U32Popcnt => Self::U32Popcnt, + Instruction::U32Lt => Self::U32Lt, + Instruction::U32Lte => Self::U32Lte, + Instruction::U32Gt => Self::U32Gt, + Instruction::U32Gte => Self::U32Gte, + Instruction::U32Min => Self::U32Min, + Instruction::U32Max => Self::U32Max, Instruction::Drop => Self::Drop, Instruction::DropW => Self::Dropw, Instruction::PadW => Self::Padw, @@ -875,11 +778,11 @@ impl MasmOp { Instruction::LocLoad(_) | Instruction::LocLoadW(_) => { unimplemented!("load by local id") } - Instruction::MemStream => unimplemented!("mem_stream"), - Instruction::AdvPipe - | Instruction::AdvPush(_) - | Instruction::AdvLoadW - | Instruction::AdvInject(_) => unimplemented!("advice provider operations"), + Instruction::MemStream => Self::MemStream, + Instruction::AdvPipe => Self::AdvPipe, + Instruction::AdvPush(byte) => Self::AdvPush(byte), + Instruction::AdvLoadW => Self::AdvLoadw, + Instruction::AdvInject(_) => unimplemented!("adv_inject"), Instruction::Hash | Instruction::HMerge | Instruction::HPerm @@ -889,27 +792,55 @@ impl MasmOp { | Instruction::MTreeVerify => unimplemented!("cryptographic operations"), Instruction::ExecLocal(local_index) => Self::Exec(locals[local_index as usize]), Instruction::ExecImported(ref proc_id) => { - let invoked = &imported.invoked_procs()[proc_id]; + let module = imported + .get_procedure_path(proc_id) + .expect("reference to import that doesn't exist") + .last(); + let name = imported + .get_procedure_name(proc_id) + .expect("reference to import that doesn't exist"); Self::Exec(FunctionIdent { - module: Ident::with_empty_span(Symbol::intern(invoked.1.last())), - function: Ident::with_empty_span(Symbol::intern(invoked.0.as_ref())), + module: Ident::with_empty_span(Symbol::intern(module)), + function: Ident::with_empty_span(Symbol::intern(name.as_ref())), }) } Instruction::CallLocal(_) | Instruction::CallMastRoot(_) | Instruction::CallImported(_) => unimplemented!("contract calls"), Instruction::SysCall(ref proc_id) => { - let invoked = &imported.invoked_procs()[proc_id]; + let module = imported + .get_procedure_path(proc_id) + .expect("reference to import that doesn't exist") + .last(); + let name = imported + .get_procedure_name(proc_id) + .expect("reference to import that doesn't exist"); Self::Syscall(FunctionIdent { - module: Ident::with_empty_span(Symbol::intern(invoked.1.last())), - function: Ident::with_empty_span(Symbol::intern(invoked.0.as_ref())), + module: Ident::with_empty_span(Symbol::intern(module)), + function: Ident::with_empty_span(Symbol::intern(name.as_ref())), + }) + } + Instruction::DynExec => Self::DynExec, + Instruction::DynCall => Self::DynCall, + Instruction::ProcRefLocal(local_index) => Self::ProcRef(locals[local_index as usize]), + Instruction::ProcRefImported(ref proc_id) => { + let module = imported + .get_procedure_path(proc_id) + .expect("reference to import that doesn't exist") + .last(); + let name = imported + .get_procedure_name(proc_id) + .expect("reference to import that doesn't exist"); + Self::ProcRef(FunctionIdent { + module: Ident::with_empty_span(Symbol::intern(module)), + function: Ident::with_empty_span(Symbol::intern(name.as_ref())), }) } - Instruction::DynExec | Instruction::DynCall => unimplemented!("indirect calls"), + Instruction::Caller => Self::Caller, Instruction::Sdepth - | Instruction::Caller | Instruction::FriExt2Fold4 | Instruction::Breakpoint + | Instruction::Emit(_) | Instruction::Debug(_) => unimplemented!("miscellaneous instructions"), }; smallvec![op] @@ -1037,9 +968,13 @@ impl MasmOp { Self::Cdrop => Instruction::CDrop, Self::Cdropw => Instruction::CDropW, Self::Assert => Instruction::Assert, + Self::AssertWithError(code) => Instruction::AssertWithError(code), Self::Assertz => Instruction::Assertz, + Self::AssertzWithError(code) => Instruction::AssertzWithError(code), Self::AssertEq => Instruction::AssertEq, + Self::AssertEqWithError(code) => Instruction::AssertEqWithError(code), Self::AssertEqw => Instruction::AssertEqw, + Self::AssertEqwWithError(code) => Instruction::AssertEqwWithError(code), Self::LocAddr(id) => Instruction::Locaddr(id.as_usize() as u16), Self::LocStore(id) => Instruction::LocStore(id.as_usize() as u16), Self::LocStorew(id) => Instruction::LocStoreW(id.as_usize() as u16), @@ -1057,6 +992,10 @@ impl MasmOp { | Self::MemStoreOffsetImm(_, _) => unimplemented!( "this is an experimental instruction that is not supported by the Miden VM" ), + Self::MemStream => Instruction::MemStream, + Self::AdvPipe => Instruction::AdvPipe, + Self::AdvPush(n) => Instruction::AdvPush(n), + Self::AdvLoadw => Instruction::AdvLoadW, Self::If(_, _) | Self::While(_) | Self::Repeat(_, _) => { panic!("control flow instructions are meant to be handled specially by the caller") } @@ -1104,6 +1043,32 @@ impl MasmOp { .unwrap_or_else(|| miden_assembly::ProcedureId::new(aliased.to_string())); Instruction::SysCall(id) } + Self::DynExec => Instruction::DynExec, + Self::DynCall => Instruction::DynCall, + Self::ProcRef(ref callee) => { + if let Some(idx) = local_ids.get(callee).copied() { + Instruction::ProcRefLocal(idx) + } else { + let aliased = if let Some(alias) = imports.alias(&callee.module) { + FunctionIdent { + module: alias, + function: callee.function, + } + } else { + let module_as_import = super::MasmImport::try_from(callee.module) + .expect("invalid module name"); + FunctionIdent { + module: Ident::with_empty_span(module_as_import.alias), + function: callee.function, + } + }; + let id = proc_ids + .get(&aliased) + .copied() + .unwrap_or_else(|| miden_assembly::ProcedureId::new(aliased.to_string())); + Instruction::ProcRefImported(id) + } + } Self::Add => Instruction::Add, Self::AddImm(imm) => Instruction::AddImm(imm), Self::Sub => Instruction::Sub, @@ -1175,101 +1140,66 @@ impl MasmOp { Self::IsOdd => Instruction::IsOdd, Self::Eqw => Instruction::Eqw, Self::Clk => Instruction::Clk, + Self::Caller => Instruction::Caller, Self::U32Test => Instruction::U32Test, Self::U32Testw => Instruction::U32TestW, Self::U32Assert => Instruction::U32Assert, + Self::U32AssertWithError(code) => Instruction::U32AssertWithError(code), Self::U32Assert2 => Instruction::U32Assert2, + Self::U32Assert2WithError(code) => Instruction::U32Assert2WithError(code), Self::U32Assertw => Instruction::U32AssertW, + Self::U32AssertwWithError(code) => Instruction::U32AssertWWithError(code), Self::U32Cast => Instruction::U32Cast, Self::U32Split => Instruction::U32Split, - Self::U32CheckedAdd => Instruction::U32CheckedAdd, - Self::U32CheckedAddImm(imm) => Instruction::U32CheckedAddImm(imm), Self::U32OverflowingAdd => Instruction::U32OverflowingAdd, Self::U32OverflowingAddImm(imm) => Instruction::U32OverflowingAddImm(imm), Self::U32WrappingAdd => Instruction::U32WrappingAdd, Self::U32WrappingAddImm(imm) => Instruction::U32WrappingAddImm(imm), Self::U32OverflowingAdd3 => Instruction::U32OverflowingAdd3, Self::U32WrappingAdd3 => Instruction::U32WrappingAdd3, - Self::U32CheckedSub => Instruction::U32CheckedSub, - Self::U32CheckedSubImm(imm) => Instruction::U32CheckedSubImm(imm), Self::U32OverflowingSub => Instruction::U32OverflowingSub, Self::U32OverflowingSubImm(imm) => Instruction::U32OverflowingSubImm(imm), Self::U32WrappingSub => Instruction::U32WrappingSub, Self::U32WrappingSubImm(imm) => Instruction::U32WrappingSubImm(imm), - Self::U32CheckedMul => Instruction::U32CheckedMul, - Self::U32CheckedMulImm(imm) => Instruction::U32CheckedMulImm(imm), Self::U32OverflowingMul => Instruction::U32OverflowingMul, Self::U32OverflowingMulImm(imm) => Instruction::U32OverflowingMulImm(imm), Self::U32WrappingMul => Instruction::U32WrappingMul, Self::U32WrappingMulImm(imm) => Instruction::U32WrappingMulImm(imm), Self::U32OverflowingMadd => Instruction::U32OverflowingMadd, Self::U32WrappingMadd => Instruction::U32WrappingMadd, - Self::U32CheckedDiv => Instruction::U32CheckedDiv, - Self::U32CheckedDivImm(imm) => Instruction::U32CheckedDivImm(imm), - Self::U32UncheckedDiv => Instruction::U32UncheckedDiv, - Self::U32UncheckedDivImm(imm) => Instruction::U32UncheckedDivImm(imm), - Self::U32CheckedMod => Instruction::U32CheckedMod, - Self::U32CheckedModImm(imm) => Instruction::U32CheckedModImm(imm), - Self::U32UncheckedMod => Instruction::U32UncheckedMod, - Self::U32UncheckedModImm(imm) => Instruction::U32UncheckedModImm(imm), - Self::U32CheckedDivMod => Instruction::U32CheckedDivMod, - Self::U32CheckedDivModImm(imm) => Instruction::U32CheckedDivModImm(imm), - Self::U32UncheckedDivMod => Instruction::U32UncheckedDivMod, - Self::U32UncheckedDivModImm(imm) => Instruction::U32UncheckedDivModImm(imm), - Self::U32And => Instruction::U32CheckedAnd, - Self::U32Or => Instruction::U32CheckedOr, - Self::U32Xor => Instruction::U32CheckedXor, - Self::U32Not => Instruction::U32CheckedNot, - Self::U32CheckedShl => Instruction::U32CheckedShl, - Self::U32CheckedShlImm(imm) => { - Instruction::U32CheckedShlImm(imm.try_into().expect("invalid rotation")) - } - Self::U32UncheckedShl => Instruction::U32UncheckedShl, - Self::U32UncheckedShlImm(imm) => { - Instruction::U32UncheckedShlImm(imm.try_into().expect("invalid rotation")) - } - Self::U32CheckedShr => Instruction::U32CheckedShr, - Self::U32CheckedShrImm(imm) => { - Instruction::U32CheckedShrImm(imm.try_into().expect("invalid rotation")) - } - Self::U32UncheckedShr => Instruction::U32UncheckedShr, - Self::U32UncheckedShrImm(imm) => { - Instruction::U32UncheckedShrImm(imm.try_into().expect("invalid rotation")) - } - Self::U32CheckedRotl => Instruction::U32CheckedRotl, - Self::U32CheckedRotlImm(imm) => { - Instruction::U32CheckedRotlImm(imm.try_into().expect("invalid rotation")) + Self::U32Div => Instruction::U32Div, + Self::U32DivImm(imm) => Instruction::U32DivImm(imm), + Self::U32Mod => Instruction::U32Mod, + Self::U32ModImm(imm) => Instruction::U32ModImm(imm), + Self::U32DivMod => Instruction::U32DivMod, + Self::U32DivModImm(imm) => Instruction::U32DivModImm(imm), + Self::U32And => Instruction::U32And, + Self::U32Or => Instruction::U32Or, + Self::U32Xor => Instruction::U32Xor, + Self::U32Not => Instruction::U32Not, + Self::U32Shl => Instruction::U32Shl, + Self::U32ShlImm(imm) => { + Instruction::U32ShlImm(imm.try_into().expect("invalid rotation")) } - Self::U32UncheckedRotl => Instruction::U32UncheckedRotl, - Self::U32UncheckedRotlImm(imm) => { - Instruction::U32UncheckedRotlImm(imm.try_into().expect("invalid rotation")) + Self::U32Shr => Instruction::U32Shr, + Self::U32ShrImm(imm) => { + Instruction::U32ShrImm(imm.try_into().expect("invalid rotation")) } - Self::U32CheckedRotr => Instruction::U32CheckedRotr, - Self::U32CheckedRotrImm(imm) => { - Instruction::U32CheckedRotrImm(imm.try_into().expect("invalid rotation")) + Self::U32Rotl => Instruction::U32Rotl, + Self::U32RotlImm(imm) => { + Instruction::U32RotlImm(imm.try_into().expect("invalid rotation")) } - Self::U32UncheckedRotr => Instruction::U32UncheckedRotr, - Self::U32UncheckedRotrImm(imm) => { - Instruction::U32UncheckedRotrImm(imm.try_into().expect("invalid rotation")) + Self::U32Rotr => Instruction::U32Rotr, + Self::U32RotrImm(imm) => { + Instruction::U32RotrImm(imm.try_into().expect("invalid rotation")) } - Self::U32CheckedPopcnt => Instruction::U32CheckedPopcnt, - Self::U32UncheckedPopcnt => Instruction::U32UncheckedPopcnt, - Self::U32Eq => Instruction::U32CheckedEq, - Self::U32EqImm(imm) => Instruction::U32CheckedEqImm(imm), - Self::U32Neq => Instruction::U32CheckedNeq, - Self::U32NeqImm(imm) => Instruction::U32CheckedNeqImm(imm), - Self::U32CheckedLt => Instruction::U32CheckedLt, - Self::U32UncheckedLt => Instruction::U32UncheckedLt, - Self::U32CheckedLte => Instruction::U32CheckedLte, - Self::U32UncheckedLte => Instruction::U32UncheckedLte, - Self::U32CheckedGt => Instruction::U32CheckedGt, - Self::U32UncheckedGt => Instruction::U32UncheckedGt, - Self::U32CheckedGte => Instruction::U32CheckedGte, - Self::U32UncheckedGte => Instruction::U32UncheckedGte, - Self::U32CheckedMin => Instruction::U32CheckedMin, - Self::U32UncheckedMin => Instruction::U32UncheckedMin, - Self::U32CheckedMax => Instruction::U32CheckedMax, - Self::U32UncheckedMax => Instruction::U32UncheckedMax, + Self::U32Popcnt => Instruction::U32Popcnt, + Self::U32Lt => Instruction::U32Lt, + Self::U32Lte => Instruction::U32Lte, + Self::U32Gt => Instruction::U32Gt, + Self::U32Gte => Instruction::U32Gte, + Self::U32Min => Instruction::U32Min, + Self::U32Max => Instruction::U32Max, }; smallvec![Node::Instruction(node)] } @@ -1301,9 +1231,13 @@ impl fmt::Display for MasmOp { Self::Cdrop => f.write_str("cdrop"), Self::Cdropw => f.write_str("cdropw"), Self::Assert => f.write_str("assert"), + Self::AssertWithError(code) => write!(f, "assert.err={code}"), Self::Assertz => f.write_str("assertz"), + Self::AssertzWithError(code) => write!(f, "assertz.err={code}"), Self::AssertEq => f.write_str("assert_eq"), + Self::AssertEqWithError(code) => write!(f, "assert_eq.err={code}"), Self::AssertEqw => f.write_str("assert_eqw"), + Self::AssertEqwWithError(code) => write!(f, "assert_eqw.err={code}"), Self::LocAddr(_) => f.write_str("locaddr"), Self::LocStore(_) => f.write_str("loc_store"), Self::LocStorew(_) => f.write_str("loc_storew"), @@ -1317,21 +1251,28 @@ impl fmt::Display for MasmOp { | Self::MemStoreImm(_) | Self::MemStoreOffsetImm(_, _) => f.write_str("mem_store"), Self::MemStorew | Self::MemStorewImm(_) => f.write_str("mem_storew"), + Self::MemStream => f.write_str("mem_stream"), + Self::AdvPipe => f.write_str("adv_pipe"), + Self::AdvPush(_) => f.write_str("adv_push"), + Self::AdvLoadw => f.write_str("adv_loadw"), Self::If(_, _) => f.write_str("if.true"), Self::While(_) => f.write_str("while.true"), Self::Repeat(_, _) => f.write_str("repeat"), Self::Exec(_) => f.write_str("exec"), Self::Syscall(_) => f.write_str("syscall"), + Self::DynExec => f.write_str("dynexec"), + Self::DynCall => f.write_str("dyncall"), + Self::ProcRef(_) => f.write_str("procref"), Self::Add | Self::AddImm(_) => f.write_str("add"), Self::Sub | Self::SubImm(_) => f.write_str("sub"), Self::Mul | Self::MulImm(_) => f.write_str("mul"), Self::Div | Self::DivImm(_) => f.write_str("div"), Self::Neg => f.write_str("neg"), Self::Inv => f.write_str("inv"), - Self::Incr => f.write_str("incr"), + Self::Incr => f.write_str("add.1"), Self::Pow2 => f.write_str("pow2"), - Self::Exp => f.write_str("exp.u64"), - Self::ExpImm(imm) => write!(f, "exp.{imm}"), + Self::Exp => f.write_str("exp"), + Self::ExpImm(imm) => write!(f, "exp.u{imm}"), Self::Not => f.write_str("not"), Self::And | Self::AndImm(_) => f.write_str("and"), Self::Or | Self::OrImm(_) => f.write_str("or"), @@ -1345,74 +1286,51 @@ impl fmt::Display for MasmOp { Self::IsOdd => f.write_str("is_odd"), Self::Eqw => f.write_str("eqw"), Self::Clk => f.write_str("clk"), + Self::Caller => f.write_str("caller"), Self::U32Test => f.write_str("u32test"), Self::U32Testw => f.write_str("u32testw"), Self::U32Assert => f.write_str("u32assert"), + Self::U32AssertWithError(code) => write!(f, "u32assert.err={code}"), Self::U32Assert2 => f.write_str("u32assert2"), + Self::U32Assert2WithError(code) => write!(f, "u32assert2.err={code}"), Self::U32Assertw => f.write_str("u32assertw"), - Self::U32Cast => f.write_str("u23cast"), + Self::U32AssertwWithError(code) => write!(f, "u32assertw.err={code}"), + Self::U32Cast => f.write_str("u32cast"), Self::U32Split => f.write_str("u32split"), - Self::U32CheckedAdd | Self::U32CheckedAddImm(_) => f.write_str("u32checked_add"), Self::U32OverflowingAdd | Self::U32OverflowingAddImm(_) => { f.write_str("u32overflowing_add") } Self::U32WrappingAdd | Self::U32WrappingAddImm(_) => f.write_str("u32wrapping_add"), Self::U32OverflowingAdd3 => f.write_str("u32overflowing_add3"), Self::U32WrappingAdd3 => f.write_str("u32wrapping_add3"), - Self::U32CheckedSub | Self::U32CheckedSubImm(_) => f.write_str("u32checked_sub"), Self::U32OverflowingSub | Self::U32OverflowingSubImm(_) => { f.write_str("u32overflowing_sub") } Self::U32WrappingSub | Self::U32WrappingSubImm(_) => f.write_str("u32wrapping_sub"), - Self::U32CheckedMul | Self::U32CheckedMulImm(_) => f.write_str("u32checked_mul"), Self::U32OverflowingMul | Self::U32OverflowingMulImm(_) => { f.write_str("u32overflowing_mul") } Self::U32WrappingMul | Self::U32WrappingMulImm(_) => f.write_str("u32wrapping_mul"), Self::U32OverflowingMadd => f.write_str("u32overflowing_madd"), Self::U32WrappingMadd => f.write_str("u32wrapping_madd"), - Self::U32CheckedDiv | Self::U32CheckedDivImm(_) => f.write_str("u32checked_div"), - Self::U32UncheckedDiv | Self::U32UncheckedDivImm(_) => f.write_str("u32unchecked_div"), - Self::U32CheckedMod | Self::U32CheckedModImm(_) => f.write_str("u32checked_mod"), - Self::U32UncheckedMod | Self::U32UncheckedModImm(_) => f.write_str("u32unchecked_mod"), - Self::U32CheckedDivMod | Self::U32CheckedDivModImm(_) => { - f.write_str("u32checked_divmod") - } - Self::U32UncheckedDivMod | Self::U32UncheckedDivModImm(_) => { - f.write_str("u32unchecked_divmod") - } - Self::U32And => f.write_str("u32checked_and"), - Self::U32Or => f.write_str("u32checked_or"), - Self::U32Xor => f.write_str("u32checked_xor"), - Self::U32Not => f.write_str("u32checked_not"), - Self::U32CheckedShl | Self::U32CheckedShlImm(_) => f.write_str("u32checked_shl"), - Self::U32UncheckedShl | Self::U32UncheckedShlImm(_) => f.write_str("u32unchecked_shl"), - Self::U32CheckedShr | Self::U32CheckedShrImm(_) => f.write_str("u32checked_shr"), - Self::U32UncheckedShr | Self::U32UncheckedShrImm(_) => f.write_str("u32unchecked_shr"), - Self::U32CheckedRotl | Self::U32CheckedRotlImm(_) => f.write_str("u32checked_rotl"), - Self::U32UncheckedRotl | Self::U32UncheckedRotlImm(_) => { - f.write_str("u32unchecked_rotl") - } - Self::U32CheckedRotr | Self::U32CheckedRotrImm(_) => f.write_str("u32checked_rotr"), - Self::U32UncheckedRotr | Self::U32UncheckedRotrImm(_) => { - f.write_str("u32unchecked_rotr") - } - Self::U32CheckedPopcnt => f.write_str("u32checked_popcnt"), - Self::U32UncheckedPopcnt => f.write_str("u32unchecked_popcnt"), - Self::U32Eq | Self::U32EqImm(_) => f.write_str("u32checked_eq"), - Self::U32Neq | Self::U32NeqImm(_) => f.write_str("u32checked_neq"), - Self::U32CheckedLt => f.write_str("u32checked_lt"), - Self::U32UncheckedLt => f.write_str("u32unchecked_lt"), - Self::U32CheckedLte => f.write_str("u32checked_lte"), - Self::U32UncheckedLte => f.write_str("u32unchecked_lte"), - Self::U32CheckedGt => f.write_str("u32checked_gt"), - Self::U32UncheckedGt => f.write_str("u32unchecked_gt"), - Self::U32CheckedGte => f.write_str("u32checked_gte"), - Self::U32UncheckedGte => f.write_str("u32unchecked_gte"), - Self::U32CheckedMin => f.write_str("u32checked_min"), - Self::U32UncheckedMin => f.write_str("u32unchecked_min"), - Self::U32CheckedMax => f.write_str("u32checked_max"), - Self::U32UncheckedMax => f.write_str("u32unchecked_max"), + Self::U32Div | Self::U32DivImm(_) => f.write_str("u32d_div"), + Self::U32Mod | Self::U32ModImm(_) => f.write_str("u32mod"), + Self::U32DivMod | Self::U32DivModImm(_) => f.write_str("u32divmod"), + Self::U32And => f.write_str("u32and"), + Self::U32Or => f.write_str("u32or"), + Self::U32Xor => f.write_str("u32xor"), + Self::U32Not => f.write_str("u32not"), + Self::U32Shl | Self::U32ShlImm(_) => f.write_str("u32shl"), + Self::U32Shr | Self::U32ShrImm(_) => f.write_str("u32shr"), + Self::U32Rotl | Self::U32RotlImm(_) => f.write_str("u32rotl"), + Self::U32Rotr | Self::U32RotrImm(_) => f.write_str("u32rotr"), + Self::U32Popcnt => f.write_str("u32popcnt"), + Self::U32Lt => f.write_str("u32lt"), + Self::U32Lte => f.write_str("u32lte"), + Self::U32Gt => f.write_str("u32gt"), + Self::U32Gte => f.write_str("u32gte"), + Self::U32Min => f.write_str("u32min"), + Self::U32Max => f.write_str("u32max"), } } } diff --git a/hir/src/immediates.rs b/hir/src/immediates.rs index 562228f33..0e0e23ab5 100644 --- a/hir/src/immediates.rs +++ b/hir/src/immediates.rs @@ -290,6 +290,30 @@ impl PartialEq for Immediate { } } } +impl PartialEq for Immediate { + fn eq(&self, other: &isize) -> bool { + let y = *other; + match *self { + Self::I1(x) => x == (y == 1), + Self::U8(_) if y < 0 => false, + Self::U8(x) => x as isize == y, + Self::I8(x) => x as isize == y, + Self::U16(_) if y < 0 => false, + Self::U16(x) => x as isize == y, + Self::I16(x) => x as isize == y, + Self::U32(_) if y < 0 => false, + Self::U32(x) => x as isize == y, + Self::I32(x) => x as isize == y, + Self::U64(_) if y < 0 => false, + Self::U64(x) => x == y as i64 as u64, + Self::I64(x) => x == y as i64, + Self::I128(x) => x == y as i128, + Self::F64(_) => false, + Self::Felt(_) if y < 0 => false, + Self::Felt(x) => x.as_int() == y as i64 as u64, + } + } +} impl PartialOrd for Immediate { fn partial_cmp(&self, other: &Self) -> Option { Some(self.cmp(other)) From dd5ea25df8c90718b468f9e92d7edeba2d7b6c95 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Sat, 18 Nov 2023 01:20:23 -0500 Subject: [PATCH 2/3] fix: properly handle emitting final artifacts in midenc-compile --- codegen/masm/src/masm/program.rs | 35 +++++++++++++++++++++ midenc-compile/src/lib.rs | 52 ++++++++++++++++++++++++++++++-- midenc-session/src/inputs.rs | 4 +++ midenc-session/src/lib.rs | 39 ++++++++++++++++++++++++ 4 files changed, 127 insertions(+), 3 deletions(-) diff --git a/codegen/masm/src/masm/program.rs b/codegen/masm/src/masm/program.rs index be2de2244..15f6be516 100644 --- a/codegen/masm/src/masm/program.rs +++ b/codegen/masm/src/masm/program.rs @@ -192,6 +192,41 @@ impl Program { Ok(Self::from_masl_library(&library, codemap)) } + pub fn to_masl_library>( + &self, + root_ns: S, + codemap: &miden_diagnostics::CodeMap, + ) -> Result { + use miden_assembly::{LibraryNamespace, MaslLibrary, Version}; + use std::collections::BTreeSet; + + let ns = LibraryNamespace::new(root_ns)?; + let version = Version::default(); + let has_source_locations = false; + let mut modules = Vec::with_capacity(self.modules.iter().count()); + let mut dependencies = BTreeSet::default(); + for module in self.modules() { + for import in module.imports.iter() { + if self.modules.get(&import.name).is_some() { + continue; + } + let root = match import.name.as_str().split_once("::") { + None => LibraryNamespace::new(import.name.as_str())?, + Some((root, _)) => LibraryNamespace::new(root)?, + }; + dependencies.insert(root); + } + modules.push(module.to_module_ast(codemap)); + } + MaslLibrary::new( + ns, + version, + has_source_locations, + modules, + dependencies.into_iter().collect(), + ) + } + /// Convert a [miden_assembly::MaslLibrary] into a [Program] pub fn from_masl_library( library: &miden_assembly::MaslLibrary, diff --git a/midenc-compile/src/lib.rs b/midenc-compile/src/lib.rs index 6b52922ed..282dd75a0 100644 --- a/midenc-compile/src/lib.rs +++ b/midenc-compile/src/lib.rs @@ -8,8 +8,9 @@ use self::stages::*; use std::sync::Arc; -use miden_hir::pass::AnalysisManager; -use midenc_session::Session; +use miden_codegen_masm as masm; +use miden_hir::{pass::AnalysisManager, Symbol}; +use midenc_session::{OutputType, Session}; pub use self::stages::Compiled; @@ -44,6 +45,9 @@ pub enum CompilerError { /// An error occurred while linking a program #[error(transparent)] Linker(#[from] miden_hir::LinkerError), + /// An error occurred while emitting a MASL library + #[error(transparent)] + Masl(#[from] miden_assembly::LibraryError), /// An error ocurred when reading a file #[error(transparent)] Io(#[from] std::io::Error), @@ -122,7 +126,49 @@ pub fn compile(session: Arc) -> CompilerResult<()> { let inputs = vec![session.input.clone()]; let mut analyses = AnalysisManager::new(); match compile_inputs(inputs, &mut analyses, &session) { - Ok(_) | Err(CompilerError::Stopped) => return Ok(()), + Ok(Compiled::Program(ref program)) => { + if let Some(path) = session.emit_to(OutputType::Masl, None) { + use miden_assembly::utils::Serializable; + let masl = program.to_masl_library(session.name(), &session.codemap)?; + let bytes = masl.to_bytes(); + std::fs::write(&path, bytes)?; + } + if session.should_emit(OutputType::Masm) { + for module in program.modules() { + session.emit(module)?; + } + if program.is_executable() { + use miden_assembly::LibraryPath; + let ast = program.to_program_ast(&session.codemap); + if let Some(path) = session.emit_to( + OutputType::Masm, + Some(Symbol::intern(LibraryPath::EXEC_PATH)), + ) { + ast.write_to_file(path)?; + } else { + println!("{ast}"); + } + } + } + } + Ok(Compiled::Modules(modules)) => { + let mut program = masm::Program::new(); + for module in modules.into_iter() { + program.insert(module); + } + if let Some(path) = session.emit_to(OutputType::Masl, None) { + use miden_assembly::utils::Serializable; + let masl = program.to_masl_library(session.name(), &session.codemap)?; + let bytes = masl.to_bytes(); + std::fs::write(&path, bytes)?; + } + if session.should_emit(OutputType::Masm) { + for module in program.modules() { + session.emit(module)?; + } + } + } + Err(CompilerError::Stopped) => return Ok(()), Err(CompilerError::Reported) => return Err(CompilerError::Reported), Err(err) => { session.diagnostics.error(err); diff --git a/midenc-session/src/inputs.rs b/midenc-session/src/inputs.rs index f03e34618..2c4584dd8 100644 --- a/midenc-session/src/inputs.rs +++ b/midenc-session/src/inputs.rs @@ -79,6 +79,10 @@ impl InputFile { } } + pub fn is_real(&self) -> bool { + matches!(self.file, InputType::Real(_)) + } + pub fn filestem(&self) -> &str { match &self.file { InputType::Real(ref path) => path.file_stem().unwrap().to_str().unwrap(), diff --git a/midenc-session/src/lib.rs b/midenc-session/src/lib.rs index 978e5f581..2a681898d 100644 --- a/midenc-session/src/lib.rs +++ b/midenc-session/src/lib.rs @@ -180,6 +180,28 @@ impl Session { &self.arg_matches } + /// The name of this session (used as the name of the project, output file, etc.) + pub fn name(&self) -> String { + self.options + .name + .clone() + .or_else(|| { + if self.input.is_real() { + Some(self.input.filestem().to_string()) + } else { + None + } + }) + .unwrap_or_else(|| { + self.options + .current_dir + .file_name() + .unwrap() + .to_string_lossy() + .into_owned() + }) + } + pub fn out_filename(&self, outputs: &OutputFiles, progname: Symbol) -> OutputFile { let default_filename = self.filename_for_input(outputs, progname); let out_filename = outputs @@ -240,6 +262,23 @@ impl Session { self.options.output_types.contains_key(&ty) } + /// Get the path to emit the given [OutputType] to + pub fn emit_to(&self, ty: OutputType, name: Option) -> Option { + if self.should_emit(ty) { + match self.output_files.path(ty) { + OutputFile::Real(path) => name + .map(|name| { + path.with_file_name(name.as_str()) + .with_extension(ty.extension()) + }) + .or(Some(path)), + OutputFile::Stdout => None, + } + } else { + None + } + } + /// Emit an item to stdout/file system depending on the current configuration pub fn emit(&self, item: &E) -> std::io::Result<()> { let output_type = item.output_type(); From 764b75feacd6ca78e921179a0e0c6d986fae9034 Mon Sep 17 00:00:00 2001 From: Paul Schoenfelder Date: Mon, 20 Nov 2023 13:10:05 -0500 Subject: [PATCH 3/3] test: update expected output after miden-assembly upgrade --- tests/integration/expected/and_bool.masm | 110 ++++++++++--------- tests/integration/expected/and_i16.masm | 110 ++++++++++--------- tests/integration/expected/and_i32.masm | 110 ++++++++++--------- tests/integration/expected/and_i8.masm | 110 ++++++++++--------- tests/integration/expected/and_u16.masm | 110 ++++++++++--------- tests/integration/expected/and_u32.masm | 110 ++++++++++--------- tests/integration/expected/and_u8.masm | 110 ++++++++++--------- tests/integration/expected/eq_i16.masm | 110 ++++++++++--------- tests/integration/expected/eq_i32.masm | 110 ++++++++++--------- tests/integration/expected/eq_i64.masm | 114 ++++++++++--------- tests/integration/expected/eq_i8.masm | 110 ++++++++++--------- tests/integration/expected/eq_u16.masm | 110 ++++++++++--------- tests/integration/expected/eq_u32.masm | 110 ++++++++++--------- tests/integration/expected/eq_u64.masm | 114 ++++++++++--------- tests/integration/expected/eq_u8.masm | 110 ++++++++++--------- tests/integration/expected/fib.masm | 133 ++++++++++++----------- tests/integration/expected/ge_u16.masm | 114 ++++++++++--------- tests/integration/expected/ge_u32.masm | 114 ++++++++++--------- tests/integration/expected/ge_u8.masm | 114 ++++++++++--------- tests/integration/expected/gt_u16.masm | 114 ++++++++++--------- tests/integration/expected/gt_u32.masm | 114 ++++++++++--------- tests/integration/expected/gt_u8.masm | 114 ++++++++++--------- tests/integration/expected/le_u16.masm | 114 ++++++++++--------- tests/integration/expected/le_u32.masm | 114 ++++++++++--------- tests/integration/expected/le_u8.masm | 114 ++++++++++--------- tests/integration/expected/lt_u16.masm | 114 ++++++++++--------- tests/integration/expected/lt_u32.masm | 114 ++++++++++--------- tests/integration/expected/lt_u8.masm | 114 ++++++++++--------- tests/integration/expected/not_bool.masm | 110 ++++++++++--------- tests/integration/expected/not_i16.masm | 110 ++++++++++--------- tests/integration/expected/not_i32.masm | 110 ++++++++++--------- tests/integration/expected/not_i8.masm | 110 ++++++++++--------- tests/integration/expected/not_u16.masm | 110 ++++++++++--------- tests/integration/expected/not_u32.masm | 110 ++++++++++--------- tests/integration/expected/not_u8.masm | 110 ++++++++++--------- tests/integration/expected/or_bool.masm | 110 ++++++++++--------- tests/integration/expected/or_i16.masm | 110 ++++++++++--------- tests/integration/expected/or_i32.masm | 110 ++++++++++--------- tests/integration/expected/or_i8.masm | 110 ++++++++++--------- tests/integration/expected/or_u16.masm | 110 ++++++++++--------- tests/integration/expected/or_u32.masm | 110 ++++++++++--------- tests/integration/expected/or_u8.masm | 110 ++++++++++--------- tests/integration/expected/shr_u16.masm | 118 +++++++++++--------- tests/integration/expected/shr_u32.masm | 116 +++++++++++--------- tests/integration/expected/shr_u8.masm | 118 +++++++++++--------- tests/integration/expected/xor_bool.masm | 110 ++++++++++--------- tests/integration/expected/xor_i16.masm | 110 ++++++++++--------- tests/integration/expected/xor_i32.masm | 110 ++++++++++--------- tests/integration/expected/xor_i8.masm | 110 ++++++++++--------- tests/integration/expected/xor_u16.masm | 110 ++++++++++--------- tests/integration/expected/xor_u32.masm | 110 ++++++++++--------- tests/integration/expected/xor_u8.masm | 110 ++++++++++--------- 52 files changed, 3175 insertions(+), 2646 deletions(-) diff --git a/tests/integration/expected/and_bool.masm b/tests/integration/expected/and_bool.masm index 8fb349f61..273d5f5ca 100644 --- a/tests/integration/expected/and_bool.masm +++ b/tests/integration/expected/and_bool.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_and + u32and end program diff --git a/tests/integration/expected/and_i16.masm b/tests/integration/expected/and_i16.masm index 8fb349f61..273d5f5ca 100644 --- a/tests/integration/expected/and_i16.masm +++ b/tests/integration/expected/and_i16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_and + u32and end program diff --git a/tests/integration/expected/and_i32.masm b/tests/integration/expected/and_i32.masm index 8fb349f61..273d5f5ca 100644 --- a/tests/integration/expected/and_i32.masm +++ b/tests/integration/expected/and_i32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_and + u32and end program diff --git a/tests/integration/expected/and_i8.masm b/tests/integration/expected/and_i8.masm index 8fb349f61..273d5f5ca 100644 --- a/tests/integration/expected/and_i8.masm +++ b/tests/integration/expected/and_i8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_and + u32and end program diff --git a/tests/integration/expected/and_u16.masm b/tests/integration/expected/and_u16.masm index 8fb349f61..273d5f5ca 100644 --- a/tests/integration/expected/and_u16.masm +++ b/tests/integration/expected/and_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_and + u32and end program diff --git a/tests/integration/expected/and_u32.masm b/tests/integration/expected/and_u32.masm index 8fb349f61..273d5f5ca 100644 --- a/tests/integration/expected/and_u32.masm +++ b/tests/integration/expected/and_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_and + u32and end program diff --git a/tests/integration/expected/and_u8.masm b/tests/integration/expected/and_u8.masm index 8fb349f61..273d5f5ca 100644 --- a/tests/integration/expected/and_u8.masm +++ b/tests/integration/expected/and_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_and + u32and end program diff --git a/tests/integration/expected/eq_i16.masm b/tests/integration/expected/eq_i16.masm index 6b833f967..14ee26a05 100644 --- a/tests/integration/expected/eq_i16.masm +++ b/tests/integration/expected/eq_i16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_eq + eq end program diff --git a/tests/integration/expected/eq_i32.masm b/tests/integration/expected/eq_i32.masm index 6b833f967..14ee26a05 100644 --- a/tests/integration/expected/eq_i32.masm +++ b/tests/integration/expected/eq_i32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_eq + eq end program diff --git a/tests/integration/expected/eq_i64.masm b/tests/integration/expected/eq_i64.masm index d3722480f..9f5564371 100644 --- a/tests/integration/expected/eq_i64.masm +++ b/tests/integration/expected/eq_i64.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,11 @@ end mod noname export.entrypoint - eqw + movup.2 + eq + movdn.3 + eq + and end program diff --git a/tests/integration/expected/eq_i8.masm b/tests/integration/expected/eq_i8.masm index 6b833f967..14ee26a05 100644 --- a/tests/integration/expected/eq_i8.masm +++ b/tests/integration/expected/eq_i8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_eq + eq end program diff --git a/tests/integration/expected/eq_u16.masm b/tests/integration/expected/eq_u16.masm index 6b833f967..14ee26a05 100644 --- a/tests/integration/expected/eq_u16.masm +++ b/tests/integration/expected/eq_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_eq + eq end program diff --git a/tests/integration/expected/eq_u32.masm b/tests/integration/expected/eq_u32.masm index 6b833f967..14ee26a05 100644 --- a/tests/integration/expected/eq_u32.masm +++ b/tests/integration/expected/eq_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_eq + eq end program diff --git a/tests/integration/expected/eq_u64.masm b/tests/integration/expected/eq_u64.masm index d3722480f..9f5564371 100644 --- a/tests/integration/expected/eq_u64.masm +++ b/tests/integration/expected/eq_u64.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,11 @@ end mod noname export.entrypoint - eqw + movup.2 + eq + movdn.3 + eq + and end program diff --git a/tests/integration/expected/eq_u8.masm b/tests/integration/expected/eq_u8.masm index 6b833f967..14ee26a05 100644 --- a/tests/integration/expected/eq_u8.masm +++ b/tests/integration/expected/eq_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_eq + eq end program diff --git a/tests/integration/expected/fib.masm b/tests/integration/expected/fib.masm index 91c2dd25c..f74bd2963 100644 --- a/tests/integration/expected/fib.masm +++ b/tests/integration/expected/fib.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -649,51 +659,52 @@ export.fib dup.0 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz push.3 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gt - u32checked_neq.0 + u32gt + neq.0 push.1 while.true if.true dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz push.3 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_div + u32d_div + u32assert dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz dup.0 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz push.3 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gt - u32checked_neq.0 + u32gt + neq.0 push.1 else push.0 diff --git a/tests/integration/expected/ge_u16.masm b/tests/integration/expected/ge_u16.masm index f780c7e1f..822c6aef8 100644 --- a/tests/integration/expected/ge_u16.masm +++ b/tests/integration/expected/ge_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gte + u32gte end program diff --git a/tests/integration/expected/ge_u32.masm b/tests/integration/expected/ge_u32.masm index f780c7e1f..822c6aef8 100644 --- a/tests/integration/expected/ge_u32.masm +++ b/tests/integration/expected/ge_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gte + u32gte end program diff --git a/tests/integration/expected/ge_u8.masm b/tests/integration/expected/ge_u8.masm index f780c7e1f..822c6aef8 100644 --- a/tests/integration/expected/ge_u8.masm +++ b/tests/integration/expected/ge_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gte + u32gte end program diff --git a/tests/integration/expected/gt_u16.masm b/tests/integration/expected/gt_u16.masm index b41df3c13..9eed54f69 100644 --- a/tests/integration/expected/gt_u16.masm +++ b/tests/integration/expected/gt_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gt + u32gt end program diff --git a/tests/integration/expected/gt_u32.masm b/tests/integration/expected/gt_u32.masm index b41df3c13..9eed54f69 100644 --- a/tests/integration/expected/gt_u32.masm +++ b/tests/integration/expected/gt_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gt + u32gt end program diff --git a/tests/integration/expected/gt_u8.masm b/tests/integration/expected/gt_u8.masm index b41df3c13..9eed54f69 100644 --- a/tests/integration/expected/gt_u8.masm +++ b/tests/integration/expected/gt_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_gt + u32gt end program diff --git a/tests/integration/expected/le_u16.masm b/tests/integration/expected/le_u16.masm index 1c0a63b4f..ffbb7f84e 100644 --- a/tests/integration/expected/le_u16.masm +++ b/tests/integration/expected/le_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_lte + u32lte end program diff --git a/tests/integration/expected/le_u32.masm b/tests/integration/expected/le_u32.masm index 1c0a63b4f..ffbb7f84e 100644 --- a/tests/integration/expected/le_u32.masm +++ b/tests/integration/expected/le_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_lte + u32lte end program diff --git a/tests/integration/expected/le_u8.masm b/tests/integration/expected/le_u8.masm index 1c0a63b4f..ffbb7f84e 100644 --- a/tests/integration/expected/le_u8.masm +++ b/tests/integration/expected/le_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_lte + u32lte end program diff --git a/tests/integration/expected/lt_u16.masm b/tests/integration/expected/lt_u16.masm index 0d15b1596..129b6f2cd 100644 --- a/tests/integration/expected/lt_u16.masm +++ b/tests/integration/expected/lt_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_lt + u32lt end program diff --git a/tests/integration/expected/lt_u32.masm b/tests/integration/expected/lt_u32.masm index 0d15b1596..129b6f2cd 100644 --- a/tests/integration/expected/lt_u32.masm +++ b/tests/integration/expected/lt_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_lt + u32lt end program diff --git a/tests/integration/expected/lt_u8.masm b/tests/integration/expected/lt_u8.masm index 0d15b1596..129b6f2cd 100644 --- a/tests/integration/expected/lt_u8.masm +++ b/tests/integration/expected/lt_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,16 +658,16 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_lt + u32lt end program diff --git a/tests/integration/expected/not_bool.masm b/tests/integration/expected/not_bool.masm index 0cf0ad972..408845297 100644 --- a/tests/integration/expected/not_bool.masm +++ b/tests/integration/expected/not_bool.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -647,7 +657,7 @@ mod noname export.entrypoint push.1 - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/not_i16.masm b/tests/integration/expected/not_i16.masm index 4329a34e4..11219e747 100644 --- a/tests/integration/expected/not_i16.masm +++ b/tests/integration/expected/not_i16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -647,7 +657,7 @@ mod noname export.entrypoint push.4294967295 - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/not_i32.masm b/tests/integration/expected/not_i32.masm index 4329a34e4..11219e747 100644 --- a/tests/integration/expected/not_i32.masm +++ b/tests/integration/expected/not_i32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -647,7 +657,7 @@ mod noname export.entrypoint push.4294967295 - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/not_i8.masm b/tests/integration/expected/not_i8.masm index 4329a34e4..11219e747 100644 --- a/tests/integration/expected/not_i8.masm +++ b/tests/integration/expected/not_i8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -647,7 +657,7 @@ mod noname export.entrypoint push.4294967295 - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/not_u16.masm b/tests/integration/expected/not_u16.masm index 333f4067a..8bbb5b72f 100644 --- a/tests/integration/expected/not_u16.masm +++ b/tests/integration/expected/not_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -647,7 +657,7 @@ mod noname export.entrypoint push.65535 - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/not_u32.masm b/tests/integration/expected/not_u32.masm index 4329a34e4..11219e747 100644 --- a/tests/integration/expected/not_u32.masm +++ b/tests/integration/expected/not_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -647,7 +657,7 @@ mod noname export.entrypoint push.4294967295 - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/not_u8.masm b/tests/integration/expected/not_u8.masm index 8e9b1b6fa..93916b711 100644 --- a/tests/integration/expected/not_u8.masm +++ b/tests/integration/expected/not_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -647,7 +657,7 @@ mod noname export.entrypoint push.255 - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/or_bool.masm b/tests/integration/expected/or_bool.masm index a0708fd77..edfb96eaa 100644 --- a/tests/integration/expected/or_bool.masm +++ b/tests/integration/expected/or_bool.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_or + u32or end program diff --git a/tests/integration/expected/or_i16.masm b/tests/integration/expected/or_i16.masm index a0708fd77..edfb96eaa 100644 --- a/tests/integration/expected/or_i16.masm +++ b/tests/integration/expected/or_i16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_or + u32or end program diff --git a/tests/integration/expected/or_i32.masm b/tests/integration/expected/or_i32.masm index a0708fd77..edfb96eaa 100644 --- a/tests/integration/expected/or_i32.masm +++ b/tests/integration/expected/or_i32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_or + u32or end program diff --git a/tests/integration/expected/or_i8.masm b/tests/integration/expected/or_i8.masm index a0708fd77..edfb96eaa 100644 --- a/tests/integration/expected/or_i8.masm +++ b/tests/integration/expected/or_i8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_or + u32or end program diff --git a/tests/integration/expected/or_u16.masm b/tests/integration/expected/or_u16.masm index a0708fd77..edfb96eaa 100644 --- a/tests/integration/expected/or_u16.masm +++ b/tests/integration/expected/or_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_or + u32or end program diff --git a/tests/integration/expected/or_u32.masm b/tests/integration/expected/or_u32.masm index a0708fd77..edfb96eaa 100644 --- a/tests/integration/expected/or_u32.masm +++ b/tests/integration/expected/or_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_or + u32or end program diff --git a/tests/integration/expected/or_u8.masm b/tests/integration/expected/or_u8.masm index a0708fd77..edfb96eaa 100644 --- a/tests/integration/expected/or_u8.masm +++ b/tests/integration/expected/or_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_or + u32or end program diff --git a/tests/integration/expected/shr_u16.masm b/tests/integration/expected/shr_u16.masm index d15924586..be94ce7f5 100644 --- a/tests/integration/expected/shr_u16.masm +++ b/tests/integration/expected/shr_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,21 +658,21 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz push.15 movup.2 - u32checked_and + u32and dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_shr + u32shr dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz end diff --git a/tests/integration/expected/shr_u32.masm b/tests/integration/expected/shr_u32.masm index bf328d7a5..d69a7a8eb 100644 --- a/tests/integration/expected/shr_u32.masm +++ b/tests/integration/expected/shr_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,19 +658,19 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz swap.1 dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_shr + u32shr dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz end diff --git a/tests/integration/expected/shr_u8.masm b/tests/integration/expected/shr_u8.masm index 010162f2a..eee92c2e1 100644 --- a/tests/integration/expected/shr_u8.masm +++ b/tests/integration/expected/shr_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -648,21 +658,21 @@ mod noname export.entrypoint dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz push.7 movup.2 - u32checked_and + u32and dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz - u32checked_shr + u32shr dup.0 push.2147483648 - u32checked_and + u32and eq.2147483648 assertz end diff --git a/tests/integration/expected/xor_bool.masm b/tests/integration/expected/xor_bool.masm index 557602302..9b0a610b5 100644 --- a/tests/integration/expected/xor_bool.masm +++ b/tests/integration/expected/xor_bool.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/xor_i16.masm b/tests/integration/expected/xor_i16.masm index 557602302..9b0a610b5 100644 --- a/tests/integration/expected/xor_i16.masm +++ b/tests/integration/expected/xor_i16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/xor_i32.masm b/tests/integration/expected/xor_i32.masm index 557602302..9b0a610b5 100644 --- a/tests/integration/expected/xor_i32.masm +++ b/tests/integration/expected/xor_i32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/xor_i8.masm b/tests/integration/expected/xor_i8.masm index 557602302..9b0a610b5 100644 --- a/tests/integration/expected/xor_i8.masm +++ b/tests/integration/expected/xor_i8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/xor_u16.masm b/tests/integration/expected/xor_u16.masm index 557602302..9b0a610b5 100644 --- a/tests/integration/expected/xor_u16.masm +++ b/tests/integration/expected/xor_u16.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/xor_u32.masm b/tests/integration/expected/xor_u32.masm index 557602302..9b0a610b5 100644 --- a/tests/integration/expected/xor_u32.masm +++ b/tests/integration/expected/xor_u32.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_xor + u32xor end program diff --git a/tests/integration/expected/xor_u8.masm b/tests/integration/expected/xor_u8.masm index 557602302..9b0a610b5 100644 --- a/tests/integration/expected/xor_u8.masm +++ b/tests/integration/expected/xor_u8.masm @@ -2,13 +2,13 @@ mod intrinsics::i32 export.is_signed push.2147483648 - u32checked_and + u32and push.2147483648 eq end export.unchecked_neg - u32checked_not + u32not u32wrapping_add.1 end @@ -180,7 +180,7 @@ export.checked_div dup.0 movdn.5 cdrop - u32unchecked_div + u32d_div movdn.2 neq dup.1 @@ -193,10 +193,10 @@ export.icmp dup.1 dup.1 push.2147483648 - u32checked_and + u32and swap.1 push.2147483648 - u32checked_and + u32and eq.0 swap.1 eq.0 @@ -215,9 +215,9 @@ export.icmp drop dup.1 dup.1 - u32unchecked_gt + u32gt movdn.2 - u32unchecked_lt + u32lt push.0 push.4294967295 push.1 @@ -253,17 +253,17 @@ end export.pow2 dup.0 push.31 - u32checked_lt + u32lt assert push.1 swap.1 - u32checked_shl + u32shl end export.ipow dup.0 push.31 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -282,18 +282,18 @@ export.ipow push.1 dup.1 push.1 - u32checked_gt + u32gt while.true dup.2 dup.1 u32wrapping_mul dup.2 push.1 - u32checked_and + u32and eq.1 cdrop swap.1 - u32checked_div.2 + u32d_div.2 movup.2 dup.0 u32wrapping_mul @@ -301,7 +301,7 @@ export.ipow movup.2 dup.1 push.1 - u32checked_gt + u32gt end swap.1 drop @@ -312,7 +312,7 @@ end export.checked_shr dup.0 push.32 - u32checked_lt + u32lt assert dup.0 eq.0 @@ -328,24 +328,26 @@ export.checked_shr else dup.1 push.2147483648 - u32checked_and + u32and push.2147483648 eq if.true swap.1 dup.1 - u32checked_shr + u32shr push.1 dup.2 - u32unchecked_shl + u32shl sub.1 push.32 movup.3 sub - u32unchecked_shl - u32checked_or + u32shl + u32or + u32assert else - u32checked_shr + u32shr + u32assert end end end @@ -393,7 +395,7 @@ export.load_sw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -413,13 +415,14 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.1 eq.1 @@ -434,13 +437,14 @@ export.load_sw movdn.2 drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else swap.1 eq.2 @@ -451,16 +455,18 @@ export.load_sw drop drop dup.2 - u32checked_shl + u32shl swap.1 push.32 movup.3 - u32checked_sub - u32checked_shr - u32checked_or + u32overflowing_sub + assertz + u32shr + u32or else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -470,8 +476,9 @@ export.load_sw drop push.32 dup.3 - u32checked_sub - u32checked_shr + u32overflowing_sub + assertz + u32shr swap.1 padw movup.4 @@ -480,8 +487,8 @@ export.load_sw drop drop movup.2 - u32checked_shl - u32checked_or + u32shl + u32or end end end @@ -490,22 +497,22 @@ end export.realign_dw dup.3 - u32checked_shl + u32shl movdn.2 dup.0 push.32 dup.4 - u32checked_shr + u32shr movup.4 - u32checked_or + u32or movdn.2 dup.3 - u32checked_shl + u32shl swap.1 push.32 movup.4 - u32checked_shr - u32checked_or + u32shr + u32or swap.1 end @@ -514,7 +521,7 @@ export.load_dw eq.0 dup.3 push.8 - u32checked_lt + u32lt assert if.true movup.2 @@ -554,7 +561,8 @@ export.load_dw drop else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -602,7 +610,8 @@ export.load_dw eq.2 if.true dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -621,7 +630,8 @@ export.load_dw exec.realign_dw else dup.0 - u32checked_add.1 + u32overflowing_add.1 + assertz padw movup.4 mem_loadw @@ -646,7 +656,7 @@ end mod noname export.entrypoint - u32checked_xor + u32xor end program