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

zkasm: i64.const #64

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion cranelift/codegen/src/isa/zkasm/inst/emit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ impl MachInstEmit for Inst {
}
&Inst::LoadConst64 { rd, imm } => {
let rd = allocs.next_writable(rd);
put_string(&format!("{imm} => {}\n", reg_name(rd.to_reg())), sink);
put_string(&format!("{imm}n => {}\n", reg_name(rd.to_reg())), sink);
}
&Inst::Unwind { ref inst } => {
put_string(&format!("Unwind\n"), sink);
Expand Down
4 changes: 3 additions & 1 deletion cranelift/codegen/src/isa/zkasm/lower/isle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ impl generated_code::Context for ZkAsmIsleContext<'_, '_, MInst, ZkAsmBackend> {
let insts = match ty {
F32 => MInst::load_fp_constant32(tmp, val as u32, alloc_tmp),
F64 => MInst::load_fp_constant64(tmp, val, alloc_tmp),
_ => MInst::load_constant_u64(tmp, val, alloc_tmp),
I32 => MInst::load_constant_u32(tmp, val, alloc_tmp),
I64 => MInst::load_constant_u64(tmp, val, alloc_tmp),
_ => panic!("Not implemented"),
};
self.emit_list(&insts);
tmp.to_reg()
Expand Down
2 changes: 2 additions & 0 deletions cranelift/filetests/src/test_zkasm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,5 +209,7 @@ mod tests {
ne,
nop,
_should_fail_unreachable,
i64_const,
i32_const,
}
}
20 changes: 20 additions & 0 deletions cranelift/zkasm_data/generated/i32_const.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
start:
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP + 1 => SP
RR :MSTORE(SP - 1)
SP + 2 => SP
B :MSTORE(SP - 1)
3 => A
3 => B
B :ASSERT
$ => B :MLOAD(SP - 1)
SP - 2 => SP
$ => RR :MLOAD(SP - 1)
SP - 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
20 changes: 20 additions & 0 deletions cranelift/zkasm_data/generated/i64_const.zkasm
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
start:
zkPC + 2 => RR
:JMP(function_1)
:JMP(finalizeExecution)
function_1:
SP + 1 => SP
RR :MSTORE(SP - 1)
SP + 2 => SP
B :MSTORE(SP - 1)
9223372036854775807n => A
9223372036854775807n => B
B :ASSERT
$ => B :MLOAD(SP - 1)
SP - 2 => SP
$ => RR :MLOAD(SP - 1)
SP - 1 => SP
:JMP(RR)
finalizeExecution:
${beforeLast()} :JMPN(finalizeExecution)
:JMP(start)
7 changes: 7 additions & 0 deletions cranelift/zkasm_data/i32_const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(module
(import "env" "assert_eq" (func $assert_eq (param i32) (param i32)))
(func $main
i32.const 3
i32.const 3
call $assert_eq)
(start $main))
7 changes: 7 additions & 0 deletions cranelift/zkasm_data/i64_const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(module
(import "env" "assert_eq" (func $assert_eq (param i64) (param i64)))
(func $main
i64.const 9223372036854775807
i64.const 9223372036854775807
call $assert_eq)
(start $main))
2 changes: 1 addition & 1 deletion crates/wasi-nn/spec