Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: memory #163

Merged
merged 3 commits into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cranelift/filetests/src/test_zkasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,5 +381,6 @@ mod tests {
i32_mul_overflows,
i64_mul_overflows,
i64_rem,
memory_i32,
}
}
170 changes: 170 additions & 0 deletions cranelift/zkasm_data/generated/memory_i32.zkasm
Original file line number Diff line number Diff line change
@@ -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"
107 changes: 107 additions & 0 deletions cranelift/zkasm_data/memory_i32.wat
Original file line number Diff line number Diff line change
@@ -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)
)
1 change: 1 addition & 0 deletions cranelift/zkasm_data/state.csv
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion docs/zkasm/test_summary.csv
Original file line number Diff line number Diff line change
@@ -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
Expand Down