0xPolygonMiden / compiler

Compiler from MidenIR to Miden Assembly

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Implement memory `OpEmitter::store_*` methods for all types

greenhat opened this issue · comments

Discovered in #177 in stdlib blake3 test while storing the Wasm __stack_pointer global variable.

All OpEmitter::store_* methods are missing the implementation (todo!).

The following Wasm code

global.get $__stack_pointer
i32.const 432
i32.sub
local.tee 3
global.set $__stack_pointer

is translated to the following IR

(let (v3 i32) (const.i32 0))
(let (v4 felt) (const.felt 0))
(let (v5 i32) (global.load i32 (global.symbol #__stack_pointer)))
(let (v6 i32) (const.i32 432))
(let (v7 i32) (sub.wrapping v5 v6))
(let (v8 (ptr i32)) (global.symbol #__stack_pointer))
(store v8 v7)

The store op codegen fails.

EDIT: Here is the unimplemented parts

fn store_quad_word(&mut self, _ptr: Option<NativePtr>) {
todo!()
}
fn store_double_word(&mut self, _ptr: Option<NativePtr>) {
todo!()
}
fn store_word(&mut self, _ptr: Option<NativePtr>) {
todo!()
}
fn store_felt(&mut self, _ptr: Option<NativePtr>) {
todo!()
}
fn store_small(&mut self, _ty: &Type, _ptr: Option<NativePtr>) {
todo!()
}
fn store_array(&mut self, _element_ty: &Type, _ptr: Option<NativePtr>) {
todo!()
}
fn store_struct(&mut self, _ty: &StructType, _ptr: Option<NativePtr>) {
todo!()
}