diff --git a/cranelift/filetests/src/test_zkasm.rs b/cranelift/filetests/src/test_zkasm.rs index 81ac0a0c4e55..eda2b20d65c0 100644 --- a/cranelift/filetests/src/test_zkasm.rs +++ b/cranelift/filetests/src/test_zkasm.rs @@ -381,5 +381,6 @@ mod tests { i32_mul_overflows, i64_mul_overflows, i64_rem, + memory_i32, } } diff --git a/cranelift/zkasm_data/generated/memory_i32.zkasm b/cranelift/zkasm_data/generated/memory_i32.zkasm new file mode 100644 index 000000000000..6879c0113188 --- /dev/null +++ b/cranelift/zkasm_data/generated/memory_i32.zkasm @@ -0,0 +1,170 @@ +start: + zkPC + 2 => RR + :JMP(function_1) + :JMP(finalizeExecution) +function_1: + SP + 1 => SP + RR :MSTORE(SP - 1) + SP + 2 => SP + E :MSTORE(SP - 1) + B :MSTORE(SP - 2) + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 97n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 97n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 1) + 98n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 2) + 99n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 25) + 122n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 97n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 97n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 1) + 98n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 2) + 99n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 25) + 122n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 25185n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 25185n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 1) + 25442n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 2) + 25699n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 25) + 122n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 25185n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 25185n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 1) + 25442n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 2) + 25699n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 25) + 122n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 1684234849n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E) + 1684234849n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 1) + 1701077858n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 2) + 1717920867n => B ;; LoadConst32 + B :ASSERT + 0n => B ;; LoadConst32 + 0 => A ;; LoadExtName(User(userextname0)) + $ => E :ADD + $ => A :MLOAD(MEM:E + 25) + 122n => B ;; LoadConst32 + B :ASSERT + $ => E :MLOAD(SP - 1) + $ => B :MLOAD(SP - 2) + SP - 2 => SP + $ => RR :MLOAD(SP - 1) + SP - 1 => SP + :JMP(RR) +finalizeExecution: + ${beforeLast()} :JMPN(finalizeExecution) + :JMP(start) +INCLUDE "helpers/2-exp.zkasm" \ No newline at end of file diff --git a/cranelift/zkasm_data/memory_i32.wat b/cranelift/zkasm_data/memory_i32.wat new file mode 100644 index 000000000000..7830fa1b3b13 --- /dev/null +++ b/cranelift/zkasm_data/memory_i32.wat @@ -0,0 +1,107 @@ +(module + (import "env" "assert_eq" (func $assert_eq (param i32) (param i32))) + (memory 1) + (data (i32.const 0) "abcdefghijklmnopqrstuvwxyz") + (func $main + i32.const 0 + i32.load8_u offset=0 + i32.const 97 + call $assert_eq + i32.const 0 + i32.load8_u align=1 + i32.const 97 + call $assert_eq + i32.const 0 + i32.load8_u offset=1 align=1 + i32.const 98 + call $assert_eq + i32.const 0 + i32.load8_u offset=2 align=1 + i32.const 99 + call $assert_eq + i32.const 0 + i32.load8_u offset=25 align=1 + i32.const 122 + call $assert_eq + i32.const 0 + i32.load8_s offset=0 + i32.const 97 + call $assert_eq + i32.const 0 + i32.load8_s align=1 + i32.const 97 + call $assert_eq + i32.const 0 + i32.load8_s offset=1 align=1 + i32.const 98 + call $assert_eq + i32.const 0 + i32.load8_s offset=2 align=1 + i32.const 99 + call $assert_eq + i32.const 0 + i32.load8_s offset=25 align=1 + i32.const 122 + call $assert_eq + i32.const 0 + i32.load16_u offset=0 + i32.const 25185 + call $assert_eq + i32.const 0 + i32.load16_u align=1 + i32.const 25185 + call $assert_eq + i32.const 0 + i32.load16_u offset=1 align=1 + i32.const 25442 + call $assert_eq + i32.const 0 + i32.load16_u offset=2 align=2 + i32.const 25699 + call $assert_eq + i32.const 0 + i32.load16_u offset=25 align=2 + i32.const 122 + call $assert_eq + i32.const 0 + i32.load16_s offset=0 + i32.const 25185 + call $assert_eq + i32.const 0 + i32.load16_s align=1 + i32.const 25185 + call $assert_eq + i32.const 0 + i32.load16_s offset=1 align=1 + i32.const 25442 + call $assert_eq + i32.const 0 + i32.load16_s offset=2 align=2 + i32.const 25699 + call $assert_eq + i32.const 0 + i32.load16_s offset=25 align=2 + i32.const 122 + call $assert_eq + i32.const 0 + i32.load offset=0 + i32.const 1684234849 + call $assert_eq + i32.const 0 + i32.load align=1 + i32.const 1684234849 + call $assert_eq + i32.const 0 + i32.load offset=1 align=1 + i32.const 1701077858 + call $assert_eq + i32.const 0 + i32.load offset=2 align=2 + i32.const 1717920867 + call $assert_eq + i32.const 0 + i32.load offset=25 align=4 + i32.const 122 + call $assert_eq) + (start $main) +) \ No newline at end of file diff --git a/cranelift/zkasm_data/state.csv b/cranelift/zkasm_data/state.csv index 501841ff48a8..acb47a6a3022 100644 --- a/cranelift/zkasm_data/state.csv +++ b/cranelift/zkasm_data/state.csv @@ -21,6 +21,7 @@ locals_simple,pass,15 lt_s,pass,54 lt_u,pass,26 memory,pass,43 +memory_i32,runtime error, mul,pass,25 ne,pass,28 nop,pass,15 diff --git a/docs/zkasm/test_summary.csv b/docs/zkasm/test_summary.csv index 7b7114f3b914..be85a99e515f 100644 --- a/docs/zkasm/test_summary.csv +++ b/docs/zkasm/test_summary.csv @@ -1,5 +1,8 @@ Suite path,Passing count,Total count,Total cycles -cranelift/zkasm_data,27,28,1027 +<<<<<<< HEAD,,, +=======,,, +>>>>>>> main,,, +cranelift/zkasm_data,27,29,1027 cranelift/zkasm_data/benchmarks/fibonacci,3,3,273057 cranelift/zkasm_data/benchmarks/sha256,0,1,0 cranelift/zkasm_data/spectest/conversions,12,24,180