Skip to content

Commit

Permalink
Merge pull request #205 from near/clz_ctz
Browse files Browse the repository at this point in the history
Generate CTZ and CLZ spectests
  • Loading branch information
aborg-dev authored Feb 5, 2024
2 parents fc50643 + 93cbdcb commit be4c275
Show file tree
Hide file tree
Showing 30 changed files with 784 additions and 28 deletions.
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_1.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
4294967295n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
0n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_2.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
0n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
32n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_3.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
32768n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
16n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_4.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
255n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
24n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_5.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
2147483648n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
0n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_6.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
1n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
31n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_7.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
2n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
30n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/clz_8.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
2147483647n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, true, types::I32)
1n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/ctz_1.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
4294967295n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, false, types::I32)
0n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/ctz_2.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
0n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, false, types::I32)
32n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/ctz_3.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
32768n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, false, types::I32)
15n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/ctz_4.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
65536n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, false, types::I32)
16n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
27 changes: 27 additions & 0 deletions cranelift/zkasm_data/spectest/i32/generated/ctz_5.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
start:
0xffff => SP
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP - 1 => SP
RR :MSTORE(SP)
C :MSTORE(SP - 1)
E :MSTORE(SP - 2)
B :MSTORE(SP - 3)
SP - 4 => SP
2147483648n => B ;; LoadConst32
FIXME: Inst::Cltz(Writable { reg: v199 }, Writable { reg: v197 }, Writable { reg: v198 }, v192, false, types::I32)
31n => B ;; LoadConst32
B :ASSERT
SP + 4 => SP
$ => C :MLOAD(SP - 1)
$ => E :MLOAD(SP - 2)
$ => B :MLOAD(SP - 3)
$ => RR :MLOAD(SP)
SP + 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
INCLUDE "helpers/2-exp.zkasm"
Loading

0 comments on commit be4c275

Please sign in to comment.